tasks.py 769 B

12345678910111213141516171819202122232425262728
  1. from celery import shared_task
  2. from glitchtip.debounced_celery_task import debounced_task, debounced_wrap
  3. from .models import (
  4. EventProjectHourlyStatistic,
  5. Project,
  6. TransactionEventProjectHourlyStatistic,
  7. )
  8. @debounced_task(lambda x, *a, **k: x)
  9. @shared_task
  10. @debounced_wrap
  11. def update_event_project_hourly_statistic(project_id: int, start_time: str):
  12. EventProjectHourlyStatistic.update(project_id, start_time)
  13. @debounced_task(lambda x, *a, **k: x)
  14. @shared_task
  15. @debounced_wrap
  16. def update_transaction_event_project_hourly_statistic(project_id: int, start_time: str):
  17. TransactionEventProjectHourlyStatistic.update(project_id, start_time)
  18. @shared_task
  19. def delete_project(project_id: int):
  20. Project.objects.get(id=project_id).force_delete()