Created
November 2, 2011 19:06
-
-
Save andymckay/1334565 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/apps/addons/cron.py b/apps/addons/cron.py | |
index e55f49b..c018074 100644 | |
--- a/apps/addons/cron.py | |
+++ b/apps/addons/cron.py | |
@@ -63,6 +63,7 @@ def _build_reverse_name_lookup(data, **kw): | |
ReverseNameLookup(webapp).add(translations.get(addon['name_id']), | |
addon['id']) | |
+ | |
# TODO(jbalogh): removed from cron on 6/27/11. If the site doesn't break, | |
# delete it. | |
@cronjobs.register | |
@@ -112,6 +113,9 @@ def _update_addons_current_version(data, **kw): | |
@cronjobs.register | |
def update_addon_average_daily_users(): | |
"""Update add-ons ADU totals.""" | |
+ if settings.IGNORE_NON_CRITICAL_CRONS: | |
+ return | |
+ | |
cursor = connections[multidb.get_slave()].cursor() | |
q = """SELECT | |
addon_id, AVG(`count`) | |
@@ -147,6 +151,9 @@ def _update_addon_average_daily_users(data, **kw): | |
@cronjobs.register | |
def update_addon_download_totals(): | |
"""Update add-on total and average downloads.""" | |
+ if settings.IGNORE_NON_CRITICAL_CRONS: | |
+ return | |
+ | |
cursor = connections[multidb.get_slave()].cursor() | |
# We need to use SQL for this until | |
# http://code.djangoproject.com/ticket/11003 is resolved | |
diff --git a/apps/stats/cron.py b/apps/stats/cron.py | |
index 10f77f5..4fc60e9 100644 | |
--- a/apps/stats/cron.py | |
+++ b/apps/stats/cron.py | |
@@ -1,5 +1,6 @@ | |
import datetime | |
+from django.conf import settings | |
from django.core.management import call_command | |
from django.db.models import Sum, Max | |
@@ -20,6 +21,8 @@ cron_log = commonware.log.getLogger('z.cron') | |
@cronjobs.register | |
def update_addons_collections_downloads(): | |
"""Update addons+collections download totals.""" | |
+ if settings.IGNORE_NON_CRITICAL_CRONS: | |
+ return | |
d = (AddonCollectionCount.objects.values('addon', 'collection') | |
.annotate(sum=Sum('count'))) | |
@@ -44,6 +47,8 @@ def update_collections_total(): | |
@cronjobs.register | |
def update_global_totals(date=None): | |
"""Update global statistics totals.""" | |
+ if settings.IGNORE_NON_CRITICAL_CRONS: | |
+ return | |
today = date or datetime.date.today() | |
today_jobs = [dict(job=job, date=today) for job in | |
@@ -68,6 +73,9 @@ def addon_total_contributions(): | |
@cronjobs.register | |
def index_latest_stats(): | |
+ if settings.IGNORE_NON_CRITICAL_CRONS: | |
+ return | |
+ | |
latest = UpdateCount.search().order_by('-date').values_dict()[0]['date'] | |
fmt = lambda d: d.strftime('%Y-%m-%d') | |
date_range = '%s:%s' % (fmt(latest), fmt(datetime.date.today())) | |
diff --git a/settings.py b/settings.py | |
index 9a880cf..f609a1f 100644 | |
--- a/settings.py | |
+++ b/settings.py | |
@@ -1288,3 +1288,7 @@ NO_LOGIN_REQUIRED_MODULES = ( | |
# Sets an upper limit on the number of users. If 0, it's ignored. If the | |
# number of users meets or exceeds this, they can't register. | |
REGISTER_USER_LIMIT = 0 | |
+ | |
+# Cron jobs that aren't critical will check this flag and not run if this | |
+# is True. | |
+IGNORE_NON_CRITICAL_CRONS = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment