tasks.py 733 B

12345678910111213141516171819202122
  1. from celery import shared_task
  2. from django.utils.dateparse import parse_datetime
  3. from glitchtip.debounced_celery_task import debounced_task, debounced_wrap
  4. from .models import EventProjectHourlyStatistic, TransactionEventProjectHourlyStatistic
  5. @debounced_task(lambda x, *a, **k: x)
  6. @shared_task
  7. @debounced_wrap
  8. def update_event_project_hourly_statistic(project_id: int, start_time: str):
  9. EventProjectHourlyStatistic.update(project_id, parse_datetime(start_time))
  10. @debounced_task(lambda x, *a, **k: x)
  11. @shared_task
  12. @debounced_wrap
  13. def update_transaction_event_project_hourly_statistic(project_id: int, start_time: str):
  14. TransactionEventProjectHourlyStatistic.update(
  15. project_id, parse_datetime(start_time)
  16. )