@cronjobs.register
def update_addon_download_totals():
 if (not waffle.switch_is_active('local-statistics-processing')):
  return False
 cursor = connections[multidb.get_slave()].cursor()
 q = 'SELECT addon_id, AVG(count), SUM(count)\n           FROM download_counts\n           USE KEY (`addon_and_count`)\n           JOIN addons ON download_counts.addon_id=addons.id\n           WHERE addons.status != %s\n           GROUP BY addon_id\n           ORDER BY addon_id'
 cursor.execute(q, [amo.STATUS_DELETED])
 d = cursor.fetchall()
 cursor.close()
 ts = [_update_addon_download_totals.subtask(args=[chunk]) for chunk in chunked(d, 250)]
 TaskSet(ts).apply_async()

@ cronjobs . register def update_addon_download_totals ( ) : if ( not waffle . switch_is_active ( 'local-statistics-processing' ) ) : return False cursor = connections [ multidb . get_slave ( ) ] . cursor ( ) q = 'SELECT addon_id, AVG(count), SUM(count)\n           FROM download_counts\n           USE KEY (`addon_and_count`)\n           JOIN addons ON download_counts.addon_id=addons.id\n           WHERE addons.status != %s\n           GROUP BY addon_id\n           ORDER BY addon_id' cursor . execute ( q , [ amo . STATUS_DELETED ] ) d = cursor . fetchall ( ) cursor . close ( ) ts = [ _update_addon_download_totals . subtask ( args = [ chunk ] ) for chunk in chunked ( d , 250 ) ] TaskSet ( ts ) . apply_async ( )
update add-on total and average downloads .