@cronjobs.register
def update_user_ratings():
 cursor = connections[multidb.get_slave()].cursor()
 q = ('   SELECT\n                addons_users.user_id as user_id,\n                AVG(rating) as avg_rating\n              FROM reviews\n                INNER JOIN versions\n                INNER JOIN addons_users\n                INNER JOIN addons\n              ON reviews.version_id = versions.id\n                AND addons.id = versions.addon_id\n                AND addons_users.addon_id = addons.id\n              WHERE reviews.reply_to IS NULL\n                AND reviews.rating > 0\n                AND addons.status IN (%s)\n              GROUP BY addons_users.user_id\n              ' % ','.join(map(str, VALID_ADDON_STATUSES)))
 cursor.execute(q)
 d = cursor.fetchall()
 cursor.close()
 ts = [update_user_ratings_task.subtask(args=[chunk]) for chunk in chunked(d, 1000)]
 TaskSet(ts).apply_async()

@ cronjobs . register def update_user_ratings ( ) : cursor = connections [ multidb . get_slave ( ) ] . cursor ( ) q = ( '   SELECT\n                addons_users.user_id as user_id,\n                AVG(rating) as avg_rating\n              FROM reviews\n                INNER JOIN versions\n                INNER JOIN addons_users\n                INNER JOIN addons\n              ON reviews.version_id = versions.id\n                AND addons.id = versions.addon_id\n                AND addons_users.addon_id = addons.id\n              WHERE reviews.reply_to IS NULL\n                AND reviews.rating > 0\n                AND addons.status IN (%s)\n              GROUP BY addons_users.user_id\n              ' % ',' . join ( map ( str , VALID_ADDON_STATUSES ) ) ) cursor . execute ( q ) d = cursor . fetchall ( ) cursor . close ( ) ts = [ update_user_ratings_task . subtask ( args = [ chunk ] ) for chunk in chunked ( d , 1000 ) ] TaskSet ( ts ) . apply_async ( )
update add-on authors ratings .