Skip to content

Commit

Permalink
fix following review
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauchamp committed Sep 25, 2024
1 parent 2b708f8 commit c4e24e9
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/xo-server/src/api/schedule.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,24 @@ delete_.params = {

export { delete_ as delete }

export async function runSequence({ idSchedules }) {
const t = new Task({ properties: { type: 'xo:schedule:sequence', name: 'Schedule sequence' } })
export async function runSequence({ schedules }) {
const t = this.tasks.create({ type: 'xo:schedule:sequence', name: 'Schedule sequence' })
await t.run(async () => {
const nb = idSchedules.length
const nb = schedules.length
const signal = Task.abortSignal
for (let i = 0; i < nb; i++) {
if (signal.aborted) {
throw new Error(signal.reason)
}
signal.throwIfAborted()
Task.set('progress', Math.round((i * 100) / nb))
const idSchedule = idSchedules[i]
const idSchedule = schedules[i]
// we can't auto resolve array parameters, we have to resolve them by hand
const schedule = await this.getSchedule(idSchedule)
const job = await this.getJob(schedule.jobId)
await this.runJob(job, schedule)
}
})
}
runSequence.permission = 'admin'
runSequence.description = 'Run a sequence of schedule, one after the other'
runSequence.description = 'Run a sequence of schedules, one after the other'
runSequence.params = {
idSchedules: { type: 'array', items: { type: 'string' } },
schedules: { type: 'array', items: { type: 'string' } },
}

0 comments on commit c4e24e9

Please sign in to comment.