# 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 # 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