diff --git a/tournaments/management/commands/check_deadlines.py b/tournaments/management/commands/check_deadlines.py index e828846..afeb645 100644 --- a/tournaments/management/commands/check_deadlines.py +++ b/tournaments/management/commands/check_deadlines.py @@ -6,5 +6,5 @@ class Command(BaseCommand): def handle(self, *args, **options): # Run the function directly (not through the task queue) - check_confirmation_deadlines(schedule=0) + check_confirmation_deadlines() self.stdout.write(self.style.SUCCESS('Successfully checked confirmation deadlines')) diff --git a/tournaments/management/commands/schedule_tasks.py b/tournaments/management/commands/schedule_tasks.py index 4a9d6d5..9ebdb3b 100644 --- a/tournaments/management/commands/schedule_tasks.py +++ b/tournaments/management/commands/schedule_tasks.py @@ -1,5 +1,5 @@ from django.core.management.base import BaseCommand -from tournaments.tasks import check_confirmation_deadlines +from tournaments.tasks import background_task_check_confirmation_deadlines from django.utils import timezone import datetime from background_task.models import Task @@ -43,7 +43,7 @@ class Command(BaseCommand): seconds_until_first_run = 0 # If somehow negative, run immediately # Schedule with seconds delay instead of a specific datetime - check_confirmation_deadlines( + background_task_check_confirmation_deadlines( schedule=int(seconds_until_first_run), # Delay in seconds before first run repeat=settings.BACKGROUND_SCHEDULED_TASK_INTERVAL * 60 # 30 minutes in seconds ) diff --git a/tournaments/tasks.py b/tournaments/tasks.py index da80931..189581b 100644 --- a/tournaments/tasks.py +++ b/tournaments/tasks.py @@ -8,6 +8,11 @@ from .models.enums import RegistrationStatus from .services.email_service import TournamentEmailService, TeamEmailType @background(schedule=settings.BACKGROUND_SCHEDULED_TASK_INTERVAL * 60) # Run every 30 minutes (30*60 seconds) +def background_task_check_confirmation_deadlines(): + #DEBUG ONLY NOT NEEDED ON PROD + print("background_task Running confirmation deadline check...") + check_confirmation_deadlines() + def check_confirmation_deadlines(): """ Periodic task to check for expired confirmation deadlines diff --git a/tournaments/urls.py b/tournaments/urls.py index ad16615..01e1a45 100644 --- a/tournaments/urls.py +++ b/tournaments/urls.py @@ -77,8 +77,3 @@ urlpatterns = [ path('activation-failed/', views.activation_failed, name='activation_failed'), path('tournaments//confirm/', views.confirm_tournament_registration, name='confirm_tournament_registration'), ] - -# Start background tasks when Django starts -if apps.is_installed('django_background_tasks') and not settings.DEBUG: - from django_background_tasks import background_task_scheduler - background_task_scheduler.start()