Skip to content

Instantly share code, notes, and snippets.

@jasonleibowitz
Last active March 10, 2023 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonleibowitz/9e51ec13fd1fb9e56bd1c3e4442cca4c to your computer and use it in GitHub Desktop.
Save jasonleibowitz/9e51ec13fd1fb9e56bd1c3e4442cca4c to your computer and use it in GitHub Desktop.
get_schedule_k1_recent_job_stats.py
from fund_admin.audited_celery.models import CeleryTask
tasks = CeleryTask.objects.filter(name__contains='create_schedule_k1s_for_fund_partners').order_by('-created_at')[:10]
for task in tasks:
created_at_str = task.created_at.strftime('%m/%d at %H:%M')
job_status = task.state
print(f'Started: {created_at_str}')
print(f'Status: {job_status}')
if job_status == 'SUCCESS':
duration = task.post_run - task.pre_run
print(f'Duration: {duration}')
else:
print(f'Exception: {task.exception}')
print('-------------------')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment