@@ -167,6 +167,15 @@ export interface GetWorkflowAggregatesInput {
167167 executorId ?: string [ ] ;
168168 queueName ?: string [ ] ;
169169 workflowIdPrefix ?: string [ ] ;
170+ workflowIDs ?: string [ ] ;
171+ authenticatedUser ?: string [ ] ;
172+ forkedFrom ?: string [ ] ;
173+ wasForkedFrom ?: boolean ;
174+ parentWorkflowID ?: string [ ] ;
175+ hasParent ?: boolean ;
176+ queuesOnly ?: boolean ;
177+ attributes ?: Record < string , unknown > ;
178+ scheduleName ?: string [ ] ;
170179}
171180
172181export interface GetStepAggregatesInput {
@@ -2982,6 +2991,37 @@ export class SystemDatabase {
29822991 whereClauses . push ( `(${ likeClauses . join ( ' OR ' ) } )` ) ;
29832992 }
29842993
2994+ addFilter ( 'workflow_uuid' , input . workflowIDs ) ;
2995+ addFilter ( 'authenticated_user' , input . authenticatedUser ) ;
2996+ addFilter ( 'forked_from' , input . forkedFrom ) ;
2997+ addFilter ( 'parent_workflow_id' , input . parentWorkflowID ) ;
2998+ addFilter ( 'schedule_name' , input . scheduleName ) ;
2999+
3000+ // Only workflows that are actively enqueued.
3001+ if ( input . queuesOnly ) {
3002+ whereClauses . push ( `queue_name IS NOT NULL` ) ;
3003+ whereClauses . push ( `status IN ($${ paramIdx } , $${ paramIdx + 1 } , $${ paramIdx + 2 } )` ) ;
3004+ params . push ( StatusString . ENQUEUED , StatusString . PENDING , StatusString . DELAYED ) ;
3005+ paramIdx += 3 ;
3006+ }
3007+
3008+ if ( input . wasForkedFrom !== undefined ) {
3009+ whereClauses . push ( `was_forked_from = $${ paramIdx } ` ) ;
3010+ params . push ( input . wasForkedFrom ) ;
3011+ paramIdx ++ ;
3012+ }
3013+
3014+ if ( input . hasParent !== undefined ) {
3015+ whereClauses . push ( input . hasParent ? `parent_workflow_id IS NOT NULL` : `parent_workflow_id IS NULL` ) ;
3016+ }
3017+
3018+ // Match workflows whose attributes JSONB contains all the given key-value pairs.
3019+ if ( input . attributes && Object . keys ( input . attributes ) . length > 0 ) {
3020+ whereClauses . push ( `attributes @> $${ paramIdx } ::jsonb` ) ;
3021+ params . push ( JSON . stringify ( input . attributes ) ) ;
3022+ paramIdx ++ ;
3023+ }
3024+
29853025 if ( input . startTime ) {
29863026 whereClauses . push ( `created_at >= $${ paramIdx } ` ) ;
29873027 params . push ( new Date ( input . startTime ) . getTime ( ) ) ;
0 commit comments