fix bg tasks

timetoconfirm
Raz 7 months ago
parent f76a74f8b7
commit e282b6b807
  1. 2
      tournaments/management/commands/check_deadlines.py
  2. 4
      tournaments/management/commands/schedule_tasks.py
  3. 5
      tournaments/tasks.py
  4. 5
      tournaments/urls.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'))

@ -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
)

@ -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

@ -77,8 +77,3 @@ urlpatterns = [
path('activation-failed/', views.activation_failed, name='activation_failed'),
path('tournaments/<str:tournament_id>/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()

Loading…
Cancel
Save