fix(plugin-workflow): fix schedule infinitely trigger when repeat not set (#926)
This commit is contained in:
parent
5992952872
commit
42dbaf3582
@ -61,10 +61,12 @@ ScheduleModes.set(SCHEDULE_MODE.CONSTANT, {
|
|||||||
},
|
},
|
||||||
trigger(workflow, date) {
|
trigger(workflow, date) {
|
||||||
const { startsOn, endsOn, repeat } = workflow.config;
|
const { startsOn, endsOn, repeat } = workflow.config;
|
||||||
if (startsOn && typeof repeat === 'number') {
|
if (startsOn) {
|
||||||
const startTime = Math.floor(Date.parse(startsOn) / 1000) * 1000;
|
const startTime = Math.floor(Date.parse(startsOn) / 1000) * 1000;
|
||||||
if (Math.round(date.getTime() - startTime) % repeat) {
|
if (typeof repeat === 'number') {
|
||||||
return;
|
if (Math.round(date.getTime() - startTime) % repeat) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.plugin.trigger(workflow, { date });
|
return this.plugin.trigger(workflow, { date });
|
||||||
@ -327,8 +329,8 @@ function nextInCycle(this: ScheduleTrigger, workflow, now: Date): boolean {
|
|||||||
}
|
}
|
||||||
export default class ScheduleTrigger extends Trigger {
|
export default class ScheduleTrigger extends Trigger {
|
||||||
static CacheRules = [
|
static CacheRules = [
|
||||||
// ({ enabled }) => enabled,
|
|
||||||
({ config, allExecuted }) => config.limit ? allExecuted < config.limit : true,
|
({ config, allExecuted }) => config.limit ? allExecuted < config.limit : true,
|
||||||
|
({ config, executed }) => !executed || config.repeat != null,
|
||||||
({ config }) => ['repeat', 'startsOn'].some(key => config[key]),
|
({ config }) => ['repeat', 'startsOn'].some(key => config[key]),
|
||||||
nextInCycle,
|
nextInCycle,
|
||||||
function(workflow, now) {
|
function(workflow, now) {
|
||||||
@ -340,6 +342,7 @@ export default class ScheduleTrigger extends Trigger {
|
|||||||
|
|
||||||
static TriggerRules = [
|
static TriggerRules = [
|
||||||
({ config, allExecuted }) => config.limit ? allExecuted < config.limit : true,
|
({ config, allExecuted }) => config.limit ? allExecuted < config.limit : true,
|
||||||
|
({ config, executed }) => !executed || config.repeat != null,
|
||||||
({ config }) => ['repeat', 'startsOn'].some(key => config[key]),
|
({ config }) => ['repeat', 'startsOn'].some(key => config[key]),
|
||||||
function (workflow, now) {
|
function (workflow, now) {
|
||||||
const { repeat } = workflow.config;
|
const { repeat } = workflow.config;
|
||||||
|
Loading…
Reference in New Issue
Block a user