fix(plugin-workflow): fix schedule trigger number type repeat (#1475)

This commit is contained in:
Junyi 2023-02-20 21:48:15 +08:00 committed by GitHub
parent 6dbff4f74c
commit 1705b10b98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,11 +51,11 @@ ScheduleModes.set(SCHEDULE_MODE.CONSTANT, {
}
if (repeat) {
if (typeof repeat === 'number'
&& repeat > this.cacheCycle
&& (timestamp - startTime) % repeat > this.cacheCycle
) {
return false;
if (typeof repeat === 'number') {
const next = timestamp - (timestamp - startTime) % repeat + repeat;
if (next <= timestamp || next > timestamp + this.cacheCycle) {
return false;
}
}
if (endsOn) {
@ -77,7 +77,6 @@ ScheduleModes.set(SCHEDULE_MODE.CONSTANT, {
const timestamp = now.getTime();
// NOTE: align to second start
const startTime = parseDateWithoutMs(startsOn);
if (!startTime || startTime > timestamp) {
return;
}
@ -498,7 +497,7 @@ export default class ScheduleTrigger extends Trigger {
const should = await this.shouldCache(workflow, now);
if (should) {
console.log('caching schedule workflow:', workflow.id);
this.plugin.app.logger.info('caching scheduled workflow will run in next minute:', workflow.id);
}
this.setCache(workflow, !should);