2024-11-10 14:34:08 +00:00
|
|
|
from datetime import timedelta
|
|
|
|
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from django.utils.timezone import now
|
|
|
|
from django_q.models import Schedule
|
|
|
|
from django_q.tasks import schedule
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = "Manually schedule the next update_converted_prices task"
|
|
|
|
|
|
|
|
def handle(self, *args, **kwargs):
|
|
|
|
if not Schedule.objects.filter(name="Update converted prices").exists():
|
|
|
|
schedule(
|
2024-11-11 00:12:09 +00:00
|
|
|
"games.tasks.convert_prices",
|
2024-11-10 14:34:08 +00:00
|
|
|
name="Update converted prices",
|
2024-11-10 23:47:48 +00:00
|
|
|
schedule_type=Schedule.MINUTES,
|
2024-11-10 22:39:03 +00:00
|
|
|
next_run=now() + timedelta(seconds=30),
|
2024-11-10 14:34:08 +00:00
|
|
|
)
|
|
|
|
self.stdout.write(
|
|
|
|
self.style.SUCCESS("Scheduled the update_converted_prices task.")
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
self.stdout.write(self.style.WARNING("Task is already scheduled."))
|