Schedule tasks hourly
This commit is contained in:
parent
527cf4ba52
commit
a32996ccc3
|
@ -2,8 +2,6 @@ from datetime import timedelta
|
||||||
|
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from django_q.models import Schedule
|
|
||||||
from django_q.tasks import schedule
|
|
||||||
|
|
||||||
|
|
||||||
class GamesConfig(AppConfig):
|
class GamesConfig(AppConfig):
|
||||||
|
@ -11,10 +9,13 @@ class GamesConfig(AppConfig):
|
||||||
name = "games"
|
name = "games"
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
|
from django_q.models import Schedule
|
||||||
|
from django_q.tasks import schedule
|
||||||
|
|
||||||
if not Schedule.objects.filter(name="Update converted prices").exists():
|
if not Schedule.objects.filter(name="Update converted prices").exists():
|
||||||
schedule(
|
schedule(
|
||||||
"games.tasks.update_converted_prices",
|
"games.convert_price.update_converted_prices",
|
||||||
name="Update converted prices",
|
name="Update converted prices",
|
||||||
schedule_type="D",
|
schedule_type=Schedule.HOURLY,
|
||||||
next_run=now() + timedelta(days=1),
|
next_run=now() + timedelta(seconds=30),
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,10 +12,10 @@ class Command(BaseCommand):
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
if not Schedule.objects.filter(name="Update converted prices").exists():
|
if not Schedule.objects.filter(name="Update converted prices").exists():
|
||||||
schedule(
|
schedule(
|
||||||
"games.tasks.update_converted_prices",
|
"games.convert_price.update_converted_prices",
|
||||||
name="Update converted prices",
|
name="Update converted prices",
|
||||||
schedule_type="D",
|
schedule_type=Schedule.HOURLY,
|
||||||
next_run=now() + timedelta(days=1),
|
next_run=now() + timedelta(seconds=30),
|
||||||
)
|
)
|
||||||
self.stdout.write(
|
self.stdout.write(
|
||||||
self.style.SUCCESS("Scheduled the update_converted_prices task.")
|
self.style.SUCCESS("Scheduled the update_converted_prices task.")
|
||||||
|
|
Loading…
Reference in New Issue