Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions backend/donations/views/common/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def get_was_last_job_recent(ngo: Ngo | None) -> bool:
last_job_date = last_ngo_job.date_created
last_job_status = last_ngo_job.status

timedelta = datetime.timedelta(0)
td = datetime.timedelta(0)
if last_job_status != JobStatusChoices.ERROR:
timedelta = datetime.timedelta(minutes=settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES)
td = datetime.timedelta(minutes=settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES)

if last_job_date > now - timedelta:
if last_job_date > now - td:
return True

return False
Expand All @@ -36,9 +36,9 @@ def archive_job_was_recent(job_status: str, job_created: datetime) -> bool:
if job_status == JobStatusChoices.ERROR:
return False

timedelta = datetime.timedelta(minutes=settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES)
td = datetime.timedelta(minutes=settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES)

if job_created > timezone.now() - timedelta:
if job_created > timezone.now() - td:
return True

return False
Expand Down
3 changes: 2 additions & 1 deletion backend/q_heartbeat/management/commands/qheartbeat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from datetime import timedelta

import psutil
from django.core.management.base import BaseCommand
Expand Down Expand Up @@ -41,7 +42,7 @@ def handle(self, *args, **options):
return

# Check if there were any successful tasks started in the past N minutes
cutoff = timezone.now() - timezone.timedelta(minutes=check_minutes)
cutoff = timezone.now() - timedelta(minutes=check_minutes)
if not Success.objects.filter(started__gte=cutoff).exists():
# If there are no successful tasks, then try to terminate the workers
logger.error("The task queue seems to be stuck, attempting to terminate it")
Expand Down
Loading