allow us to skip unimportant crons on servers like dev
This commit is contained in:
Родитель
9c50eda710
Коммит
89eb68496a
|
@ -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
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче