-
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
fix(admin/task-processor): handle no task run #3196
Conversation
Return None for last_run_status if task does not have any run
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Uffizzi Preview |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3196 +/- ##
=======================================
Coverage 96.02% 96.02%
=======================================
Files 1062 1062
Lines 32220 32221 +1
=======================================
+ Hits 30938 30939 +1
Misses 1282 1282 ☔ View full report in Codecov by Sentry. |
api/task_processor/admin.py
Outdated
def last_run_status(self, instance: RecurringTask) -> Optional[str]: | ||
return getattr( | ||
instance.task_runs.order_by("-started_at").first(), "result", None | ||
) |
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.
def last_run_status(self, instance: RecurringTask) -> Optional[str]: | |
return getattr( | |
instance.task_runs.order_by("-started_at").first(), "result", None | |
) | |
def last_run_status(self, instance: RecurringTask) -> Optional[str]: | |
if last_run := instance.task_runs.order_by("-started_at").first(): | |
return last_run.result | |
return None |
Slight preference for this aethetically but have approved regardless.
Thanks for submitting a PR! Please check the boxes below:
pre-commit
to check lintingdocs/
if required so people know about the feature!Changes
Return None for last_run status if recurring task runs don't exist
How did you test this code?
By making sure the admin panel for recurring tasks(http://localhost:8000/admin/task_processor/recurringtask/) loads fine
for tasks that don't have any task run