-
Notifications
You must be signed in to change notification settings - Fork 429
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(tasks-processor): Add recurring task to clean up old recurring task runs #3151
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Uffizzi Preview |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3151 +/- ##
==========================================
+ Coverage 95.95% 96.11% +0.15%
==========================================
Files 1053 1058 +5
Lines 31588 31914 +326
==========================================
+ Hits 30311 30673 +362
+ Misses 1277 1241 -36 ☔ View full report in Codecov by Sentry. |
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.
Added a couple of comments but I'm happy to just approve this if you think the approach here is correct.
RECURRING_TASK_RUN_RETENTION_DAYS = env.int( | ||
"RECURRING_TASK_RUN_RETENTION_DAYS", default=30 | ||
) |
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.
Is there a reason not to use the same retention period for both types of task?
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.
Yeah, I think we probably want to control this independently, e.g: we can probably go with a lower value here because it's not as critical as tasks?
@register_recurring_task( | ||
run_every=settings.TASK_DELETE_RUN_EVERY, | ||
first_run_time=settings.TASK_DELETE_RUN_TIME, | ||
) | ||
def clean_up_old_recurring_task_runs(): | ||
if not settings.ENABLE_CLEAN_UP_OLD_TASKS: | ||
return | ||
|
||
now = timezone.now() | ||
delete_before = now - timedelta(days=settings.RECURRING_TASK_RUN_RETENTION_DAYS) | ||
|
||
RecurringTaskRun.objects.filter(finished_at__lt=delete_before).delete() |
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.
Is there a reason that we shouldn't just use the same task as the one which removes regular tasks / task runs?
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.
Yeah, it's because of the name of the task mostly
Thanks for submitting a PR! Please check the boxes below:
pre-commit
to check lintingdocs/
if required, so people know about the feature!Changes
Add a recurring task to delete recurring task runs older than
RECURRING_TASK_RUN_RETENTION_DAYS
How did you test this code?