fix(backend): Use new scheduler plugin for assign_backups

This commit is contained in:
Ferdinand Thiessen 2021-12-06 23:49:27 +01:00
parent 960a19dae8
commit d200370975
1 changed files with 3 additions and 3 deletions

View File

@ -10,7 +10,7 @@ from sqlalchemy.orm.util import was_deleted
from flaschengeist import logger
from flaschengeist.database import db
from flaschengeist.plugins import before_delete_user
from flaschengeist.utils.scheduler import scheduled
from flaschengeist.plugins.scheduler import scheduled
from . import EventPlugin
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():
logger.debug("Notifications")
now = datetime.now(tz=timezone.utc)
# now + backup_time + next cron tick
start = now + timedelta(hours=16) + timedelta(minutes=30)
services = Service.query.filter(Service.is_backup == True).join(Job).filter(Job.start <= start).all()
for service in services:
if service.job_.start <= now or service.job_.is_full():