Skip to content
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

Merged
merged 2 commits into from
Dec 20, 2023

Conversation

gagantrivedi
Copy link
Member

@gagantrivedi gagantrivedi commented Dec 20, 2023

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

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

Return None for last_run_status if task does not have any run
Copy link

vercel bot commented Dec 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2023 0:48am
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2023 0:48am
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2023 0:48am

Copy link
Contributor

github-actions bot commented Dec 20, 2023

Uffizzi Preview deployment-43261 was deleted.

@codecov-commenter
Copy link

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (6898253) 96.02% compared to head (aa9704b) 96.02%.
Report is 1 commits behind head on main.

Files Patch % Lines
api/task_processor/admin.py 66.66% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Comment on lines 19 to 22
def last_run_status(self, instance: RecurringTask) -> Optional[str]:
return getattr(
instance.task_runs.order_by("-started_at").first(), "result", None
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants