doorcontrol: Move task scheduling into doorcontrol.apps directly

This commit is contained in:
Adam Goldsmith 2023-12-01 23:50:41 -05:00
parent a50112c534
commit ba58d90bf7
2 changed files with 11 additions and 13 deletions

View File

@ -3,9 +3,18 @@ from django.db.models.signals import post_migrate
def post_migrate_callback(sender, **kwargs): def post_migrate_callback(sender, **kwargs):
from .tasks.scrapehidevents import schedule_tasks from django_q.models import Schedule
schedule_tasks() from cmsmanage.django_q2_helper import ensure_scheduled
from .tasks.scrapehidevents import q_getMessagesAllDoors
ensure_scheduled(
"Fetch HID Events",
q_getMessagesAllDoors,
schedule_type=Schedule.MINUTES,
minutes=15,
)
class DoorControlConfig(AppConfig): class DoorControlConfig(AppConfig):

View File

@ -4,9 +4,7 @@ from django.db import transaction
from django.utils import timezone from django.utils import timezone
from django_q.tasks import async_task from django_q.tasks import async_task
from django_q.models import Schedule
from cmsmanage.django_q2_helper import ensure_scheduled
from doorcontrol.models import Door, HIDEvent from doorcontrol.models import Door, HIDEvent
@ -45,12 +43,3 @@ def q_getMessagesAllDoors():
cluster="internal", cluster="internal",
group=f"Fetch HID Events - {door.name}", group=f"Fetch HID Events - {door.name}",
) )
def schedule_tasks():
ensure_scheduled(
"Fetch HID Events",
q_getMessagesAllDoors,
schedule_type=Schedule.MINUTES,
minutes=15,
)