You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

33 lines
1.2 KiB

# Shows admins the leaderboard exactly as the API publishes it.
#
# The endpoint serves a cached payload, so this reads that same cache entry
# rather than recomputing -- otherwise the screen would show numbers nobody is
# actually being served. When the cache has expired the screen falls back to a
# preview of what the next API call will publish, and says so.
class Admin::LeaderboardController < Admin::AdminController
# Guests may read the leaderboard but not drop what the API is serving.
before_action :only_admin!, only: :expire
# GET /admin/:locale/leaderboard
def index
@published = LeaderboardPayload.published
@live = @published.nil?
@payload = @published || LeaderboardPayload.build
@leaderboard = @payload[:leaderboard]
@badges = @payload[:badges]
@updated_at = @payload[:updated_at]
end
# DELETE /admin/:locale/leaderboard/cache
#
# Drops the published payload so the next API call recomputes. Handy when
# headcounts or weights change and you don't want to wait out the TTL.
def expire
LeaderboardPayload.expire!
redirect_to admin_leaderboard_path, notice: t(:leaderboard_expired, scope: 'utils')
end
end