-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat(datatrakWeb): RN-1341: Repeating tasks #5844
Merged
Merged
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
1b1fb78
WIP rrule
alexd-bes 1371391
Working rrule utils
alexd-bes f76f87c
Add generic rrule handler
alexd-bes d7b90de
frequency enum
alexd-bes d4b00bc
types
alexd-bes 3f08a8b
handle repeat schedule in task changes
alexd-bes b4ac8ea
Create and edit repeating tasks
alexd-bes 45f3506
Handle system comments
alexd-bes f3d7f02
Creating and editing with comments
alexd-bes 408f7fa
WIP
alexd-bes 681d156
Update filtering
alexd-bes d7fdc37
disable sort by repeat frequency
alexd-bes 35e2661
Add next occurrence handler
alexd-bes 755c120
Apply due date to completed tasks
alexd-bes 0caedc9
Merge branch 'epic-tasks' into rn-1341-rrule-tasks
alexd-bes 351c4fd
Handle bugs
alexd-bes cb4e8b7
Update tests
alexd-bes 73db3c5
Merge branch 'epic-tasks' into rn-1341-rrule-tasks
alexd-bes 3745b58
Merge branch 'epic-tasks' into rn-1341-rrule-tasks
alexd-bes a6f809f
Update yarn.lock
alexd-bes f8c5f1c
Merge branch 'epic-tasks' into rn-1341-rrule-tasks
alexd-bes 5a7afeb
Mark due date of tasks
alexd-bes d90b81b
Merge branch 'epic-tasks' into rn-1341-rrule-tasks
alexd-bes 5b2ad88
Comments and tidy ups
alexd-bes b4a1e0b
Use timestamp for due date
alexd-bes 199356b
Fix tests
alexd-bes 72b76e5
Merge branch 'epic-tasks' into rn-1341-rrule-tasks
alexd-bes 680440d
add comments
alexd-bes 651aa7e
Move getRepeatScheduleOptions
alexd-bes d40e292
Remove duplicate identifier
alexd-bes 989872c
Allow removing of repeat schedule
alexd-bes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Tupaia | ||
* Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd | ||
*/ | ||
import winston from 'winston'; | ||
import { getNextOccurrence } from '@tupaia/utils'; | ||
import { ScheduledTask } from './ScheduledTask'; | ||
|
||
export class RepeatingTaskDueDateHandler extends ScheduledTask { | ||
constructor(models) { | ||
// run RepeatingTaskDueDateHandler every hour | ||
super(models, 'RepeatingTaskDueDateHandler', '0 * * * *'); | ||
} | ||
|
||
async run() { | ||
const { task } = this.models; | ||
// find all repeating tasks that have passed their current due date | ||
const repeatingTasks = await task.find({ | ||
task_status: 'repeating', | ||
due_date: { comparator: '<', comparisonValue: new Date().getTime() }, | ||
}); | ||
|
||
winston.info(`Found ${repeatingTasks.length} repeating task(s)`); | ||
|
||
// update the due date for each repeating task to the next occurrence | ||
for (const repeatingTask of repeatingTasks) { | ||
const { repeat_schedule: repeatSchedule } = repeatingTask; | ||
|
||
const nextDueDate = getNextOccurrence({ | ||
...repeatSchedule, | ||
dtstart: new Date(repeatSchedule.dtstart), // convert string to date because rrule.js expects a Date object | ||
}); | ||
|
||
repeatingTask.due_date = nextDueDate; | ||
await repeatingTask.save(); | ||
|
||
winston.info(`Updated due date for task ${repeatingTask.id} to ${nextDueDate}`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's not very obvious what is going on here. Could you add a comment or example of the output format to help?