BO 1.34+3 cron
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ class NotificationJob(CronJobBase):
|
||||
print(datetime.datetime.now(), " *** END notification ")
|
||||
|
||||
|
||||
class TrialJob(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
|
||||
@@ -37,5 +36,17 @@ class TrialJob(CronJobBase):
|
||||
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 ")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user