diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 2418ea0baf..6be9d5529e 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -344,83 +344,83 @@ SUB_MARSEY_URL_LENGTH = 60 ################################################################################ PERMS = { # Minimum admin_level to perform action. - 'HOLE_CREATE': 0, - 'USER_BLOCKS_VISIBLE': 0, - 'USER_FOLLOWS_VISIBLE': 0, - 'USER_VOTERS_VISIBLE': 0, - 'VIEW_PENDING_SUBMITTED_EMOJIS': 0, + 'HOLE_CREATE': 0, + 'USER_BLOCKS_VISIBLE': 0, + 'USER_FOLLOWS_VISIBLE': 0, + 'USER_VOTERS_VISIBLE': 0, + 'VIEW_PENDING_SUBMITTED_EMOJIS': 0, - 'POST_COMMENT_DISTINGUISH': 1, - 'POST_IN_GHOST_THREADS': 1, - 'VIEW_RESTRICTED_HOLES': 1, + 'POST_COMMENT_DISTINGUISH': 1, + 'POST_IN_GHOST_THREADS': 1, + 'VIEW_RESTRICTED_HOLES': 1, 'BYPASS_SITE_READ_ONLY_MODE': 1, 'BYPASS_UNDER_SIEGE_MODE': 1, 'BYPASS_CHAT_TRUESCORE_REQUIREMENT': 1, 'BYPASS_ANTISPAM_CHECKS': 1, 'BYPASS_PROFILE_VIEWS': 1, 'WARN_ON_FAILED_LOGIN': 1, - 'NOTIFICATIONS_REDDIT': 1, - 'NOTIFICATIONS_SPECIFIC_WPD_COMMENTS': 1, - 'MESSAGE_BLOCKED_USERS': 1, - 'ADMIN_MOP_VISIBLE': 1, - 'ADMIN_HOME_VISIBLE': 1, - 'REPORTS_REMOVE': 1, - 'POST_COMMENT_MODERATION': 1, - 'USER_BAN': 1, - 'USER_SHADOWBAN': 1, - 'USER_CHUD': 1, - 'USER_MODERATION_TOOLS_VISIBLE': 1, - 'VIEW_MODMAIL': 1, - 'NOTIFICATIONS_MODMAIL': 1, - 'VIEW_PRIVATE_PROFILES': 1, - 'VIEW_ALTS': 1, - 'VIEW_ACTIVE_USERS': 1, - 'VIEW_ALT_VOTES': 1, - 'VIEW_LAST_ACTIVE': 1, - 'VIEW_VOTE_BUTTONS_ON_USER_PAGE': 1, - 'NOTIFICATIONS_HOLE_INACTIVITY_DELETION': 1, - 'NOTIFICATIONS_HOLE_CREATION': 1, - 'NOTIFICATIONS_MODERATOR_ACTIONS': 1, + 'NOTIFICATIONS_REDDIT': 1, + 'NOTIFICATIONS_SPECIFIC_WPD_COMMENTS': 1, + 'MESSAGE_BLOCKED_USERS': 1, + 'ADMIN_MOP_VISIBLE': 1, + 'ADMIN_HOME_VISIBLE': 1, + 'REPORTS_REMOVE': 1, + 'POST_COMMENT_MODERATION': 1, + 'USER_BAN': 1, + 'USER_SHADOWBAN': 1, + 'USER_CHUD': 1, + 'USER_MODERATION_TOOLS_VISIBLE': 1, + 'VIEW_MODMAIL': 1, + 'NOTIFICATIONS_MODMAIL': 1, + 'VIEW_PRIVATE_PROFILES': 1, + 'VIEW_ALTS': 1, + 'VIEW_ACTIVE_USERS': 1, + 'VIEW_ALT_VOTES': 1, + 'VIEW_LAST_ACTIVE': 1, + 'VIEW_VOTE_BUTTONS_ON_USER_PAGE': 1, + 'NOTIFICATIONS_HOLE_INACTIVITY_DELETION': 1, + 'NOTIFICATIONS_HOLE_CREATION': 1, + 'NOTIFICATIONS_MODERATOR_ACTIONS': 1, 'IS_PERMA_PROGSTACKED': 2, - 'USER_BADGES': 2, - 'USER_LINK': 2, - 'USER_TITLE_CHANGE': 2, - 'LOTTERY_VIEW_PARTICIPANTS': 2, - 'POST_COMMENT_INFINITE_PINGS': 2, + 'USER_BADGES': 2, + 'USER_LINK': 2, + 'USER_TITLE_CHANGE': 2, + 'LOTTERY_VIEW_PARTICIPANTS': 2, + 'POST_COMMENT_INFINITE_PINGS': 2, 'IGNORE_1WEEk_EDITING_LIMIT': 2, 'ORGIES': 2, - 'ADMIN_REMOVE': 3, - 'ADMIN_ACTIONS_REVERT': 3, - 'DOMAINS_BAN': 3, - 'EDIT_RULES': 3, - 'POST_BETS': 3, - 'POST_BETS_DISTRIBUTE': 3, - 'VIEW_PENDING_SUBMITTED_HATS': 3, - 'LOTTERY_ADMIN': 3, - 'SITE_SETTINGS': 3, - 'SITE_CACHE_PURGE_CDN': 3, - 'NOTIFICATIONS_FROM_SHADOWBANNED_USERS': 3, - 'APPS_MODERATION': 3, - 'USE_ADMIGGER_THREADS': 3, + 'ADMIN_REMOVE': 3, + 'ADMIN_ACTIONS_REVERT': 3, + 'DOMAINS_BAN': 3, + 'EDIT_RULES': 3, + 'POST_BETS': 3, + 'POST_BETS_DISTRIBUTE': 3, + 'VIEW_PENDING_SUBMITTED_HATS': 3, + 'LOTTERY_ADMIN': 3, + 'SITE_SETTINGS': 3, + 'SITE_CACHE_PURGE_CDN': 3, + 'NOTIFICATIONS_FROM_SHADOWBANNED_USERS': 3, + 'APPS_MODERATION': 3, + 'USE_ADMIGGER_THREADS': 3, 'IGNORE_AWARD_IMMUNITY': 3, - 'MODERATE_PENDING_SUBMITTED_ASSETS': 3, - 'UPDATE_ASSETS': 3, + 'MODERATE_PENDING_SUBMITTED_ASSETS': 3, + 'UPDATE_ASSETS': 3, 'UNDO_AWARD_PINS': 3, 'DELETE_MEDIA': 3, 'PROGSTACK': 4, - 'ADMIN_ADD': 4, + 'ADMIN_ADD': 4, 'USER_BLACKLIST': 4, - 'POST_COMMENT_EDITING': 4, - 'VIEW_PATRONS': 4, - 'BLACKJACK_NOTIFICATIONS': 4, - 'IGNORE_BADGE_BLACKLIST': 4, - 'ENABLE_DM_MEDIA': 4, - 'SEE_GHOST_VOTES': 4, + 'POST_COMMENT_EDITING': 4, + 'VIEW_PATRONS': 4, + 'BLACKJACK_NOTIFICATIONS': 4, + 'IGNORE_BADGE_BLACKLIST': 4, + 'ENABLE_DM_MEDIA': 4, + 'SEE_GHOST_VOTES': 4, 'SITE_OFFLINE_MODE': 4, - 'MODS_EVERY_HOLE': 4, + 'MODS_EVERY_HOLE': 4, 'MODS_EVERY_GROUP': 4, 'IGNORE_DOMAIN_BAN': 4, 'USER_RESET_PASSWORD': 4, diff --git a/files/routes/special.py b/files/routes/special.py index 45c02caa7d..d3ad71a2dc 100644 --- a/files/routes/special.py +++ b/files/routes/special.py @@ -10,87 +10,87 @@ # _special_leaderboard_query = text(""" # WITH bet_options AS ( -# SELECT p.id AS parent_id, so.id AS option_id, so.exclusive, cnt.count -# FROM post_options so -# JOIN posts p ON so.parent_id = p.id -# JOIN ( -# SELECT option_id, COUNT(*) FROM post_option_votes -# GROUP BY option_id -# ) AS cnt ON so.id = cnt.option_id -# WHERE p.author_id = 7465 AND p.created_utc > 1688950032 -# AND so.exclusive IN (2, 3) AND p.title ilike 'women''s world cup betting: %' +# SELECT p.id AS parent_id, so.id AS option_id, so.exclusive, cnt.count +# FROM post_options so +# JOIN posts p ON so.parent_id = p.id +# JOIN ( +# SELECT option_id, COUNT(*) FROM post_option_votes +# GROUP BY option_id +# ) AS cnt ON so.id = cnt.option_id +# WHERE p.author_id = 7465 AND p.created_utc > 1688950032 +# AND so.exclusive IN (2, 3) AND p.title ilike 'women''s world cup betting: %' # ), # post_payouts AS ( -# SELECT -# sq_total.parent_id, -# sq_winners.sum AS bettors, -# floor((sq_total.sum * 200) / sq_winners.sum) AS winner_payout -# FROM ( -# SELECT parent_id, SUM(count) -# FROM bet_options GROUP BY parent_id -# ) AS sq_total -# JOIN ( -# SELECT parent_id, SUM(count) -# FROM bet_options WHERE exclusive = 3 GROUP BY parent_id -# ) AS sq_winners ON sq_total.parent_id = sq_winners.parent_id +# SELECT +# sq_total.parent_id, +# sq_winners.sum AS bettors, +# floor((sq_total.sum * 200) / sq_winners.sum) AS winner_payout +# FROM ( +# SELECT parent_id, SUM(count) +# FROM bet_options GROUP BY parent_id +# ) AS sq_total +# JOIN ( +# SELECT parent_id, SUM(count) +# FROM bet_options WHERE exclusive = 3 GROUP BY parent_id +# ) AS sq_winners ON sq_total.parent_id = sq_winners.parent_id # ), # bet_votes AS ( -# SELECT -# opt.option_id AS option_id, -# opt.exclusive, -# sov.user_id, -# CASE -# WHEN opt.exclusive = 2 THEN -200 -# WHEN opt.exclusive = 3 THEN (post_payouts.winner_payout - 200) -# END payout -# FROM post_option_votes sov -# LEFT OUTER JOIN bet_options AS opt -# ON opt.option_id = sov.option_id -# LEFT OUTER JOIN post_payouts -# ON opt.parent_id = post_payouts.parent_id -# WHERE opt.option_id IS NOT NULL +# SELECT +# opt.option_id AS option_id, +# opt.exclusive, +# sov.user_id, +# CASE +# WHEN opt.exclusive = 2 THEN -200 +# WHEN opt.exclusive = 3 THEN (post_payouts.winner_payout - 200) +# END payout +# FROM post_option_votes sov +# LEFT OUTER JOIN bet_options AS opt +# ON opt.option_id = sov.option_id +# LEFT OUTER JOIN post_payouts +# ON opt.parent_id = post_payouts.parent_id +# WHERE opt.option_id IS NOT NULL # ), # bettors AS ( -# SELECT -# COALESCE(bet_won.user_id, bet_lost.user_id) AS user_id, -# (COALESCE(bet_won.count_won, 0) -# + COALESCE(bet_lost.count_lost, 0)) AS bets_total, -# COALESCE(bet_won.count_won, 0) AS bets_won -# FROM ( -# SELECT user_id, COUNT(*) AS count_won FROM bet_votes -# WHERE exclusive = 3 GROUP BY user_id) AS bet_won -# FULL OUTER JOIN ( -# SELECT user_id, COUNT(*) AS count_lost FROM bet_votes -# WHERE exclusive = 2 GROUP BY user_id -# ) AS bet_lost ON bet_won.user_id = bet_lost.user_id +# SELECT +# COALESCE(bet_won.user_id, bet_lost.user_id) AS user_id, +# (COALESCE(bet_won.count_won, 0) +# + COALESCE(bet_lost.count_lost, 0)) AS bets_total, +# COALESCE(bet_won.count_won, 0) AS bets_won +# FROM ( +# SELECT user_id, COUNT(*) AS count_won FROM bet_votes +# WHERE exclusive = 3 GROUP BY user_id) AS bet_won +# FULL OUTER JOIN ( +# SELECT user_id, COUNT(*) AS count_lost FROM bet_votes +# WHERE exclusive = 2 GROUP BY user_id +# ) AS bet_lost ON bet_won.user_id = bet_lost.user_id # ) # SELECT -# bettors.user_id, -# bettors.bets_won, -# bettors.bets_total, -# bet_payout.net AS payout +# bettors.user_id, +# bettors.bets_won, +# bettors.bets_total, +# bet_payout.net AS payout # FROM bettors # LEFT OUTER JOIN ( -# SELECT user_id, SUM(payout) AS net FROM bet_votes GROUP BY user_id +# SELECT user_id, SUM(payout) AS net FROM bet_votes GROUP BY user_id # ) AS bet_payout ON bettors.user_id = bet_payout.user_id # ORDER BY payout DESC, bets_won DESC, bets_total ASC; # """) # @cache.memoize() # def _special_leaderboard_get(): -# result = g.db.execute(_special_leaderboard_query).all() -# return result +# result = g.db.execute(_special_leaderboard_query).all() +# return result # @app.get('/womenworldcup2023') # @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) # @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) # @auth_required # def get_leaderboard(v): -# if SITE_NAME != 'rDrama': -# abort(404) +# if SITE_NAME != 'rDrama': +# abort(404) -# result = _special_leaderboard_get() -# if g.is_api_or_xhr: return result -# users = get_accounts_dict([r[0] for r in result], v=v, graceful=True) -# return render_template("special/worldcup22_leaderboard.html", -# v=v, result=result, users=users) +# result = _special_leaderboard_get() +# if g.is_api_or_xhr: return result +# users = get_accounts_dict([r[0] for r in result], v=v, graceful=True) +# return render_template("special/worldcup22_leaderboard.html", +# v=v, result=result, users=users)