workouttest_backoffice/aitrainer_backoffice/controlling/cron/cron.py
Tibor Bossanyi (Freelancer) a4a6a5ef36 BO 1.34+3 cron
2021-12-01 00:58:40 +01:00

53 lines
1.6 KiB
Python

from ..automation.notification import NotificationExec
from ..automation.mautic import Mautic
from django_cron import CronJobBase, Schedule
import datetime
class MyCronJob(CronJobBase):
RUN_EVERY_MINS = 60
schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
code = 'aitrainer_backoffice.controlling.cron' # a unique code
def do(self):
print(datetime.datetime.now(), " *** START sync customers ")
class NotificationJob(CronJobBase):
notif = NotificationExec()
RUN_EVERY_MINS = 5
schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
code = 'aitrainer_backoffice.controlling.notification' # a unique code
def do(self):
print(datetime.datetime.now(), " *** START notification ")
self.notif.run()
print(datetime.datetime.now(), " *** END notification ")
class TrialJob(CronJobBase):
RUN_EVERY_MINS = 60
schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
code = 'aitrainer_backoffice.controlling.trial_sync' # a unique code
def do(self):
print(datetime.datetime.now(), " *** START trial sync ")
mautic = Mautic()
mautic.syncTrial()
print(datetime.datetime.now(), " *** END trial sync ")
class LangJob(CronJobBase):
RUN_EVERY_MINS = 60
schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
code = 'aitrainer_backoffice.controlling.Lang_sync' # a unique code
def do(self):
print(datetime.datetime.now(), " *** START Lang sync ")
mautic = Mautic()
mautic.syncLang()
print(datetime.datetime.now(), " *** END Lang sync ")