mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 04:20:17 +02:00
Crontab fixes
This commit is contained in:
parent
02214b74d0
commit
c1e2449084
@ -20,6 +20,10 @@ class OffsetDatabaseScheduler(DatabaseScheduler):
|
|||||||
Takes the Celery Schedule from local.py and applies our AA Framework Cron Offset, if apply_offset is true
|
Takes the Celery Schedule from local.py and applies our AA Framework Cron Offset, if apply_offset is true
|
||||||
Otherwise it passes it through as normal
|
Otherwise it passes it through as normal
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def update_from_dict(self, mapping):
|
def update_from_dict(self, mapping):
|
||||||
s = {}
|
s = {}
|
||||||
|
|
||||||
@ -36,10 +40,10 @@ class OffsetDatabaseScheduler(DatabaseScheduler):
|
|||||||
|
|
||||||
for name, entry_fields in mapping.items():
|
for name, entry_fields in mapping.items():
|
||||||
try:
|
try:
|
||||||
apply_offset = entry_fields.pop("apply_offset", False)
|
apply_offset = entry_fields.pop("apply_offset", False) # Ensure this pops before django tries to save to ORM
|
||||||
entry = self.Entry.from_entry(name, app=self.app, **entry_fields)
|
entry = self.Entry.from_entry(name, app=self.app, **entry_fields)
|
||||||
|
|
||||||
if entry.model.enabled and apply_offset:
|
if apply_offset:
|
||||||
schedule_obj = entry.schedule
|
schedule_obj = entry.schedule
|
||||||
if isinstance(schedule_obj, schedules.crontab):
|
if isinstance(schedule_obj, schedules.crontab):
|
||||||
offset_cs = CrontabSchedule.from_schedule(offset_cron(schedule_obj))
|
offset_cs = CrontabSchedule.from_schedule(offset_cron(schedule_obj))
|
||||||
@ -55,7 +59,8 @@ class OffsetDatabaseScheduler(DatabaseScheduler):
|
|||||||
entry.model.save()
|
entry.model.save()
|
||||||
logger.debug(f"Offset applied for '{name}' due to 'apply_offset' = True.")
|
logger.debug(f"Offset applied for '{name}' due to 'apply_offset' = True.")
|
||||||
|
|
||||||
s[name] = entry
|
if entry.model.enabled:
|
||||||
|
s[name] = entry
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("Error updating schedule for %s: %r", name, e)
|
logger.exception("Error updating schedule for %s: %r", name, e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user