doorcontrol: Move task scheduling into doorcontrol.apps directly
This commit is contained in:
parent
a50112c534
commit
ba58d90bf7
@ -3,9 +3,18 @@ from django.db.models.signals import post_migrate
|
||||
|
||||
|
||||
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):
|
||||
|
@ -4,9 +4,7 @@ from django.db import transaction
|
||||
from django.utils import timezone
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -45,12 +43,3 @@ def q_getMessagesAllDoors():
|
||||
cluster="internal",
|
||||
group=f"Fetch HID Events - {door.name}",
|
||||
)
|
||||
|
||||
|
||||
def schedule_tasks():
|
||||
ensure_scheduled(
|
||||
"Fetch HID Events",
|
||||
q_getMessagesAllDoors,
|
||||
schedule_type=Schedule.MINUTES,
|
||||
minutes=15,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user