timetracker/games/apps.py

21 lines
614 B
Python
Raw Normal View History

from datetime import timedelta
2022-12-31 13:18:27 +00:00
from django.apps import AppConfig
from django.utils.timezone import now
from django_q.models import Schedule
from django_q.tasks import schedule
2022-12-31 13:18:27 +00:00
class GamesConfig(AppConfig):
2022-12-31 13:18:27 +00:00
default_auto_field = "django.db.models.BigAutoField"
name = "games"
def ready(self):
if not Schedule.objects.filter(name="Update converted prices").exists():
schedule(
"games.tasks.update_converted_prices",
name="Update converted prices",
schedule_type="D",
next_run=now() + timedelta(days=1),
)