fix(backend): Use new scheduler plugin for assign_backups
This commit is contained in:
parent
960a19dae8
commit
d200370975
|
@ -10,7 +10,7 @@ from sqlalchemy.orm.util import was_deleted
|
||||||
from flaschengeist import logger
|
from flaschengeist import logger
|
||||||
from flaschengeist.database import db
|
from flaschengeist.database import db
|
||||||
from flaschengeist.plugins import before_delete_user
|
from flaschengeist.plugins import before_delete_user
|
||||||
from flaschengeist.utils.scheduler import scheduled
|
from flaschengeist.plugins.scheduler import scheduled
|
||||||
|
|
||||||
from . import EventPlugin
|
from . import EventPlugin
|
||||||
from .models import EventType, Event, Invitation, Job, JobType, Service
|
from .models import EventType, Event, Invitation, Job, JobType, Service
|
||||||
|
@ -386,12 +386,12 @@ def respond_invitation(invite: Invitation, accepted=True):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@scheduled
|
@scheduled(id='dev.flaschengeist.events.assign_backups', minutes=30)
|
||||||
def assign_backups():
|
def assign_backups():
|
||||||
logger.debug("Notifications")
|
|
||||||
now = datetime.now(tz=timezone.utc)
|
now = datetime.now(tz=timezone.utc)
|
||||||
# now + backup_time + next cron tick
|
# now + backup_time + next cron tick
|
||||||
start = now + timedelta(hours=16) + timedelta(minutes=30)
|
start = now + timedelta(hours=16) + timedelta(minutes=30)
|
||||||
|
|
||||||
services = Service.query.filter(Service.is_backup == True).join(Job).filter(Job.start <= start).all()
|
services = Service.query.filter(Service.is_backup == True).join(Job).filter(Job.start <= start).all()
|
||||||
for service in services:
|
for service in services:
|
||||||
if service.job_.start <= now or service.job_.is_full():
|
if service.job_.start <= now or service.job_.is_full():
|
||||||
|
|
Loading…
Reference in New Issue