Skip to content

Commit a9bb8f6

Browse files
committed
filter
1 parent 7953bed commit a9bb8f6

4 files changed

Lines changed: 377 additions & 0 deletions

File tree

src/conductor/conductor.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,15 @@ export class Conductor {
773773
executorId: aggBody.executor_id,
774774
queueName: aggBody.queue_name,
775775
workflowIdPrefix: aggBody.workflow_id_prefix,
776+
workflowIDs: aggBody.workflow_uuids,
777+
authenticatedUser: aggBody.authenticated_user,
778+
forkedFrom: aggBody.forked_from,
779+
parentWorkflowID: aggBody.parent_workflow_id,
780+
scheduleName: aggBody.schedule_name,
781+
queuesOnly: aggBody.queues_only,
782+
wasForkedFrom: aggBody.was_forked_from,
783+
hasParent: aggBody.has_parent,
784+
attributes: aggBody.attributes,
776785
});
777786
aggOutput = rows.map((r) => ({
778787
group: r.group,

src/conductor/protocol.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,15 @@ export interface GetWorkflowAggregatesBody {
862862
executor_id?: string[];
863863
queue_name?: string[];
864864
workflow_id_prefix?: string[];
865+
workflow_uuids?: string[];
866+
authenticated_user?: string[];
867+
forked_from?: string[];
868+
parent_workflow_id?: string[];
869+
schedule_name?: string[];
870+
queues_only?: boolean;
871+
was_forked_from?: boolean;
872+
has_parent?: boolean;
873+
attributes?: Record<string, unknown>;
865874
}
866875

867876
export class GetWorkflowAggregatesRequest implements BaseMessage {

src/system_database.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

172181
export 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

Comments
 (0)