BO 1.34+3 cron
This commit is contained in:
parent
5bbb165de5
commit
a4a6a5ef36
@ -21,6 +21,7 @@ DEBUG = False
|
||||
ALLOWED_HOSTS = ['62.171.188.119',
|
||||
"admin.aitrainer.app",
|
||||
'mail.aitrainer.info',
|
||||
'mail.aitrainer.app'
|
||||
'aitrainer.info',
|
||||
'www.aitrainer.info',
|
||||
'aitrainer.app',
|
||||
@ -181,4 +182,6 @@ LOGGING = {
|
||||
|
||||
CRON_CLASSES = [
|
||||
'controlling.cron.cron.NotificationJob',
|
||||
'controlling.cron.cron.TrialJob',
|
||||
'controlling.cron.cron.LangJob',
|
||||
]
|
||||
|
@ -14,11 +14,6 @@ else:
|
||||
|
||||
class Mautic:
|
||||
|
||||
def syncTrial(self):
|
||||
tenDays = datetime.datetime - datetime.timedelta(days=10)
|
||||
qs = Customer.objects.raw(
|
||||
'SELECT * from customer WHERE trial_date < "' + tenDays + '" and trial_date is not null')
|
||||
|
||||
def syncLang(self):
|
||||
qs = Customer.objects.raw('SELECT * from customer WHERE lang is not null and lang_sync is null')
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -33,12 +28,12 @@ class Mautic:
|
||||
data = "mauticform[email]=" + customer.email + \
|
||||
"&mauticform[database_id]=" + str(customer.customer_id) + \
|
||||
"&mauticform[lang]=" + str(customer.lang) + \
|
||||
"&mauticform[formId]=3" + \
|
||||
"&mauticform[formId]=7" + \
|
||||
"&mauticform[formName]=appdatachange"
|
||||
|
||||
print(data)
|
||||
|
||||
form_url = 'https://mautic.aitrainer.app/form/submit?formId=3'
|
||||
form_url = 'https://mautic.aitrainer.app/form/submit?formId=7'
|
||||
response = requests.post(form_url, data=data.encode('utf-8'), headers=headers)
|
||||
print(customer.email + " " +str(response.status_code))
|
||||
|
||||
@ -54,7 +49,7 @@ class Mautic:
|
||||
return True
|
||||
|
||||
def syncTrial(self):
|
||||
qs = Customer.objects.raw('SELECT * from customer WHERE trial_date is not null and trial_date_sync is null')
|
||||
qs = Customer.objects.raw('SELECT * from customer WHERE trial_date is not null and trial_date != "1900-01-01 00:00:00 00:00" and trial_date_sync is null')
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info("Syncronising trial date...")
|
||||
|
||||
@ -67,12 +62,12 @@ class Mautic:
|
||||
data = "mauticform[email]=" + customer.email + \
|
||||
"&mauticform[database_id]=" + str(customer.customer_id) + \
|
||||
"&mauticform[trialdate]=" + str(customer.trial_date) + \
|
||||
"&mauticform[formId]=3" + \
|
||||
"&mauticform[formId]=7" + \
|
||||
"&mauticform[formName]=appdatachange"
|
||||
|
||||
print(data)
|
||||
|
||||
form_url = 'https://mautic.aitrainer.app/form/submit?formId=3'
|
||||
form_url = 'https://mautic.aitrainer.app/form/submit?formId=7'
|
||||
response = requests.post(form_url, data=data.encode('utf-8'), headers=headers)
|
||||
print(customer.email + " " +str(response.status_code))
|
||||
|
||||
|
@ -27,7 +27,6 @@ class NotificationJob(CronJobBase):
|
||||
|
||||
|
||||
class TrialJob(CronJobBase):
|
||||
|
||||
RUN_EVERY_MINS = 60
|
||||
schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
|
||||
code = 'aitrainer_backoffice.controlling.trial_sync' # a unique code
|
||||
@ -39,3 +38,15 @@ class TrialJob(CronJobBase):
|
||||
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 ")
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@ services:
|
||||
- GOOGLE_APPLICATION_CREDENTIALS=/aitrainer_backoffice/aitrainer_backoffice/aitrainer_backoffice/asset/aitrainer-firebase-adminsdk.json
|
||||
- WORKOUTTEST_SETTING=PROD
|
||||
command: gunicorn aitrainer_backoffice.aitrainer_backoffice.wsgi --env DJANGO_SETTINGS_MODULE=aitrainer_backoffice.aitrainer_backoffice.settings.prod --bind 0.0.0.0:8000 --workers 3
|
||||
|
||||
cronjobs:
|
||||
build:
|
||||
context: .
|
||||
|
Loading…
Reference in New Issue
Block a user