@cronjobs.register
def update_addon_average_daily_users():
 if (not waffle.switch_is_active('local-statistics-processing')):
  return False
 raise_if_reindex_in_progress('amo')
 cursor = connections[multidb.get_slave()].cursor()
 q = 'SELECT addon_id, AVG(`count`)\n           FROM update_counts\n           WHERE `date` > DATE_SUB(CURDATE(), INTERVAL 7 DAY)\n           GROUP BY addon_id\n           ORDER BY addon_id'
 cursor.execute(q)
 d = cursor.fetchall()
 cursor.close()
 ts = [_update_addon_average_daily_users.subtask(args=[chunk]) for chunk in chunked(d, 250)]
 TaskSet(ts).apply_async()

@ cronjobs . register def update_addon_average_daily_users ( ) : if ( not waffle . switch_is_active ( 'local-statistics-processing' ) ) : return False raise_if_reindex_in_progress ( 'amo' ) cursor = connections [ multidb . get_slave ( ) ] . cursor ( ) q = 'SELECT addon_id, AVG(`count`)\n           FROM update_counts\n           WHERE `date` > DATE_SUB(CURDATE(), INTERVAL 7 DAY)\n           GROUP BY addon_id\n           ORDER BY addon_id' cursor . execute ( q ) d = cursor . fetchall ( ) cursor . close ( ) ts = [ _update_addon_average_daily_users . subtask ( args = [ chunk ] ) for chunk in chunked ( d , 250 ) ] TaskSet ( ts ) . apply_async ( )
update add-ons adu totals .