mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix(plugin-workflow): fix schedule event on date field (#4953)
This commit is contained in:
parent
5b1bd1e5fa
commit
a70ef41c1c
@ -377,5 +377,30 @@ describe('workflow > triggers > schedule > date field mode', () => {
|
|||||||
const e2c = await workflow.countExecutions();
|
const e2c = await workflow.countExecutions();
|
||||||
expect(e2c).toBe(2);
|
expect(e2c).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('empty endsOn as no end', async () => {
|
||||||
|
const workflow = await WorkflowModel.create({
|
||||||
|
enabled: true,
|
||||||
|
type: 'schedule',
|
||||||
|
config: {
|
||||||
|
mode: 1,
|
||||||
|
collection: 'posts',
|
||||||
|
startsOn: {
|
||||||
|
field: 'createdAt',
|
||||||
|
},
|
||||||
|
repeat: 1000,
|
||||||
|
endsOn: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await sleepToEvenSecond();
|
||||||
|
|
||||||
|
const post = await PostRepo.create({ values: { title: 't1' } });
|
||||||
|
|
||||||
|
await sleep(1700);
|
||||||
|
|
||||||
|
const e1c = await workflow.countExecutions();
|
||||||
|
expect(e1c).toBe(2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -54,7 +54,7 @@ function getDataOptionTime(record, on, dir = 1) {
|
|||||||
}
|
}
|
||||||
case 'object': {
|
case 'object': {
|
||||||
const { field, offset = 0, unit = 1000 } = on;
|
const { field, offset = 0, unit = 1000 } = on;
|
||||||
if (!record.get(field)) {
|
if (!field || !record.get(field)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const second = new Date(record.get(field).getTime());
|
const second = new Date(record.get(field).getTime());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user