feat(core): add 'startedBefore' execution filter prop

This commit is contained in:
Csaba Tuncsik 2023-03-01 13:35:53 +01:00
parent de56350661
commit fbcb4bc8d9

View file

@ -51,6 +51,7 @@ interface IGetExecutionsQueryFilter {
waitTill?: FindOperator<any> | boolean;
metadata?: Array<{ key: string; value: string }>;
startedAfter?: string;
startedBefore?: string;
}
const schemaGetExecutionsQueryFilter = {
@ -70,6 +71,7 @@ const schemaGetExecutionsQueryFilter = {
workflowId: { anyOf: [{ type: 'integer' }, { type: 'string' }] },
metadata: { type: 'array', items: { $ref: '#/$defs/metadata' } },
startedAfter: { type: 'date-time' },
startedBefore: { type: 'date-time' },
},
$defs: {
metadata: {
@ -188,6 +190,10 @@ export class ExecutionsService {
if ('startedAfter' in filter) {
delete filter.startedAfter;
}
if ('startedBefore' in filter) {
delete filter.startedBefore;
}
}
}
@ -333,6 +339,14 @@ export class ExecutionsService {
});
}
if (filter?.startedBefore) {
query = query.andWhere({
startedAt: LessThanOrEqual(
DateUtils.mixedDateToUtcDatetimeString(new Date(filter.startedBefore)),
),
});
}
// deepcopy breaks the In operator so we need to reapply it
if (filter?.status) {
Object.assign(filter, { status: In(filter.status) });