added automation tasks

pull/94/head
eric 2020-03-04 14:37:40 -05:00
parent 95a78815e9
commit 6705583c89
3 changed files with 35 additions and 0 deletions

View File

@ -13,6 +13,7 @@ django imports
from django.conf import settings
from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.core.management import call_command
from django.utils.timezone import now
from notification.engine import send_all
from notification import models as notification
@ -217,3 +218,8 @@ def notify_unclaimed_gifts():
if unclaimed_duration > 0 and unclaimed_duration % 7 == 0 : # first notice in 7 days
notification.send_now([gift.acq.user], "purchase_gift_waiting", {'gift':gift}, True)
notification.send_now([gift.giver], "purchase_notgot_gift", {'gift':gift}, True)
@task
def periodic_cleanup():
call_command('clearsessions')
call_command('cleanupregistration')

17
frontend/tasks.py Normal file
View File

@ -0,0 +1,17 @@
from os.path import join
from datetime import date
from celery.task import task
from django.conf import settings
from django.template.loader import get_template, render_to_string
from .views import InfoPageView
@task
def save_info_page():
page_view = InfoPageView()
page = render_to_string(page_view.template_name, context=page_view.get_context_data())
today = date.today().isoformat()
with open(join(settings.PROJECT_DIR, 'logs', 'metrics-%s.html' % today), 'w') as todays_metrics:
todays_metrics.write(page)

View File

@ -414,6 +414,18 @@ NOTIFY_UNCLAIMED_GIFTS = {
"args": ()
}
SAVE_INFO_PAGE = {
"task": "regluit.frontend.tasks.save_info_page",
"schedule": crontab(minute=25),
"args": ()
}
PERIODIC_CLEANUP = {
"task": "regluit.core.tasks.periodic_cleanup",
"schedule": crontab( minute=30),
"args": ()
}
# by default, in common, we don't turn any of the celerybeat jobs on -- turn them on in the local settings file
# set notification queueing on