forked from mfitzp/smrtr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcron.py
56 lines (46 loc) · 2.26 KB
/
cron.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from django.core.management import setup_environ
import settings
import datetime
setup_environ(settings)
from django.db.models import Avg, Max, Min, Count, Q
from django.contrib.sitemaps import ping_google
# Smrtr
from questions.utils import *
from challenge.utils import *
from package.utils import *
from profiles.utils import *
from network.utils import *
def cron():
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update question SQ..."
batch_question_update_sq()
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update question ttc..."
batch_question_update_ttc()
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update challenge SQ..."
batch_challenge_update_sq()
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update package SQ..."
batch_package_update_sq()
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update network SQ..."
batch_network_update_sq()
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update user profile SQ..."
batch_user_update_sq()
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Normalise user profile SQ..."
batch_user_normalise_sq()
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update user challenge SQ..."
batch_userchallenge_update_sq()
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update user package SQ..."
batch_userpackage_update_sq()
# Following are now calculated on completion of packages
# print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update user challenge statistics..."
# batch_userchallenge_update_statistics()
# print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update user package statistics..."
# batch_userpackage_update_statistics()
# Still calculate this on cron as focus can change overtime
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Update user challenge focus..."
batch_userchallenge_update_focus()
# Don't ping google with sitemap when developing (be nice)
from settings import DEBUG
if DEBUG == False:
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Pinging Google with sitemap..."
ping_google()
print datetime.datetime.now().strftime(' %H:%M:%S') + ": Done."
cron()