@cronjobs.register
def category_totals():
 log.debug('Starting category counts update...')
 addon_statuses = ','.join((['%s'] * len(VALID_ADDON_STATUSES)))
 file_statuses = ','.join((['%s'] * len(VALID_FILE_STATUSES)))
 cursor = connection.cursor()
 cursor.execute(('\n    UPDATE categories AS t INNER JOIN (\n     SELECT at.category_id, COUNT(DISTINCT Addon.id) AS ct\n      FROM addons AS Addon\n      INNER JOIN versions AS Version ON (Addon.id = Version.addon_id)\n      INNER JOIN applications_versions AS av ON (av.version_id = Version.id)\n      INNER JOIN addons_categories AS at ON (at.addon_id = Addon.id)\n      INNER JOIN files AS File ON (Version.id = File.version_id\n                                   AND File.status IN (%s))\n      WHERE Addon.status IN (%s) AND Addon.inactive = 0\n      GROUP BY at.category_id)\n    AS j ON (t.id = j.category_id)\n    SET t.count = j.ct\n    ' % (file_statuses, addon_statuses)), (VALID_FILE_STATUSES + VALID_ADDON_STATUSES))

@ cronjobs . register def category_totals ( ) : log . debug ( 'Starting category counts update...' ) addon_statuses = ',' . join ( ( [ '%s' ] * len ( VALID_ADDON_STATUSES ) ) ) file_statuses = ',' . join ( ( [ '%s' ] * len ( VALID_FILE_STATUSES ) ) ) cursor = connection . cursor ( ) cursor . execute ( ( '\n    UPDATE categories AS t INNER JOIN (\n     SELECT at.category_id, COUNT(DISTINCT Addon.id) AS ct\n      FROM addons AS Addon\n      INNER JOIN versions AS Version ON (Addon.id = Version.addon_id)\n      INNER JOIN applications_versions AS av ON (av.version_id = Version.id)\n      INNER JOIN addons_categories AS at ON (at.addon_id = Addon.id)\n      INNER JOIN files AS File ON (Version.id = File.version_id\n                                   AND File.status IN (%s))\n      WHERE Addon.status IN (%s) AND Addon.inactive = 0\n      GROUP BY at.category_id)\n    AS j ON (t.id = j.category_id)\n    SET t.count = j.ct\n    ' % ( file_statuses , addon_statuses ) ) , ( VALID_FILE_STATUSES + VALID_ADDON_STATUSES ) )
update category counts for sidebar navigation .