@cronjobs.register
def update_global_totals(date=None):
 raise_if_reindex_in_progress('amo')
 if date:
  date = datetime.datetime.strptime(date, '%Y-%m-%d').date()
 today = (date or (datetime.date.today() - datetime.timedelta(days=1)))
 today_jobs = [dict(job=job, date=today) for job in tasks._get_daily_jobs(date)]
 max_update = (date or UpdateCount.objects.aggregate(max=Max('date'))['max'])
 metrics_jobs = [dict(job=job, date=max_update) for job in tasks._get_metrics_jobs(date)]
 ts = [tasks.update_global_totals.subtask(kwargs=kw) for kw in (today_jobs + metrics_jobs)]
 TaskSet(ts).apply_async()

@ cronjobs . register def update_global_totals ( date = None ) : raise_if_reindex_in_progress ( 'amo' ) if date : date = datetime . datetime . strptime ( date , '%Y-%m-%d' ) . date ( ) today = ( date or ( datetime . date . today ( ) - datetime . timedelta ( days = 1 ) ) ) today_jobs = [ dict ( job = job , date = today ) for job in tasks . _get_daily_jobs ( date ) ] max_update = ( date or UpdateCount . objects . aggregate ( max = Max ( 'date' ) ) [ 'max' ] ) metrics_jobs = [ dict ( job = job , date = max_update ) for job in tasks . _get_metrics_jobs ( date ) ] ts = [ tasks . update_global_totals . subtask ( kwargs = kw ) for kw in ( today_jobs + metrics_jobs ) ] TaskSet ( ts ) . apply_async ( )
update global statistics totals .