fix ttc bugs

timetoconfirm
Raz 7 months ago
parent 715972b115
commit 147a69a7df
  1. 25
      tournaments/apps.py

@ -1,4 +1,7 @@
from django.apps import AppConfig from django.apps import AppConfig
import logging
logger = logging.getLogger(__name__)
class TournamentsConfig(AppConfig): class TournamentsConfig(AppConfig):
name = 'tournaments' name = 'tournaments'
@ -9,16 +12,12 @@ class TournamentsConfig(AppConfig):
# Start background tasks in production # Start background tasks in production
# Schedule background tasks on startup # Schedule background tasks on startup
from django.conf import settings from django.conf import settings
if not settings.DEBUG: # Only in production # Prevent running during database migrations or tests
try: from django.core.management import call_command
from background_task.models import Task try:
from tournaments.tasks import check_confirmation_deadlines # Only schedule in production
if not settings.DEBUG:
# Clear existing tasks first to avoid duplicates # Use the management command to schedule tasks
Task.objects.filter(task_name='tournaments.tasks.check_confirmation_deadlines').delete() call_command('schedule_tasks')
except Exception as e:
# Schedule the task to run every 30 minutes (1800 seconds) logger.error(f"Failed to schedule background tasks: {e}")
check_confirmation_deadlines(repeat=settings.BACKGROUND_TASK_REPEAT_INTERVAL * 60)
except:
# Handle exceptions during startup
pass

Loading…
Cancel
Save