-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(cron): get next run date/time from backend #3643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -481,6 +481,7 @@ export default { | |
| showInfo: true, | ||
| cronFormatError: null, | ||
| runAtInput: '', | ||
| cronNextRunTime: null, | ||
| }; | ||
| }, | ||
|
|
||
|
|
@@ -598,13 +599,7 @@ export default { | |
| return parsed.toDate(); | ||
| } | ||
|
|
||
| try { | ||
| return CronExpressionParser.parse(this.item.cron_format, { | ||
| tz: this.timezone, | ||
| }).next().toDate(); | ||
| } catch { | ||
| return null; | ||
| } | ||
| return this.cronNextRunTime; | ||
| }, | ||
|
|
||
| refreshCheckboxes() { | ||
|
|
@@ -675,6 +670,27 @@ export default { | |
| this.months = fields.month.values; | ||
| this.timing = 'yearly'; | ||
| } | ||
|
|
||
| this.fetchCronNextRunTime(); | ||
| }, | ||
|
|
||
| async fetchCronNextRunTime() { | ||
| if (!this.item.cron_format || this.type === 'run_at') { | ||
| this.cronNextRunTime = null; | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| const resp = await axios({ | ||
| method: 'post', | ||
| url: `/api/project/${this.projectId}/schedules/next`, | ||
| data: { cron_format: this.item.cron_format }, | ||
| responseType: 'json', | ||
| }); | ||
| this.cronNextRunTime = new Date(resp.data.next_run_time); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The API explicitly returns Useful? React with 👍 / 👎. |
||
| } catch { | ||
| this.cronNextRunTime = null; | ||
| } | ||
| }, | ||
|
|
||
| afterLoadData() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
andSchedule.Nextstops scanning att.AddDate(4, 0, 0), but valid day-of-month/day-of-week intersections can be much farther away (for example,0 0 29 2 1only matches when Feb 29 is Monday, which is often >4 years out). In those cases this returns zero and both/schedules/nextand the real scheduler path (SchedulePool.addRunner) treat the schedule as having no future run, so valid cron jobs are silently never scheduled.Useful? React with 👍 / 👎.