From 35097201b2dbadce5b647f881b83dbe5e73d5f39 Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Mon, 16 Aug 2021 16:54:35 +0900 Subject: [PATCH] Fix reading final state --- portal/app/controllers/api/admin/dashboards_controller.rb | 2 +- portal/app/controllers/api/audience/dashboards_controller.rb | 2 +- portal/app/controllers/api/contestant/dashboards_controller.rb | 2 +- portal/app/jobs/update_contestant_dashboard_job.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/portal/app/controllers/api/admin/dashboards_controller.rb b/portal/app/controllers/api/admin/dashboards_controller.rb index 67478f23..d1fe558e 100644 --- a/portal/app/controllers/api/admin/dashboards_controller.rb +++ b/portal/app/controllers/api/admin/dashboards_controller.rb @@ -4,7 +4,7 @@ class Api::Admin::DashboardsController < Api::Admin::ApplicationController pb :show, Isuxportal::Proto::Services::Admin::DashboardQuery def show - final = Rails.application.config.x.final ? "final" : "qualify" + final = Rails.application.config.x.contest.final ? "final" : "qualify" clar_count = Clarification.unanswered.requested.count cached_lb = Rails.cache.read("leaderboard:#{final}:admin")&.yield_self { |_| Isuxportal::Proto::Resources::Leaderboard.decode(_) } render protobuf: Isuxportal::Proto::Services::Admin::DashboardResponse.new( diff --git a/portal/app/controllers/api/audience/dashboards_controller.rb b/portal/app/controllers/api/audience/dashboards_controller.rb index 04eb2182..70097f14 100644 --- a/portal/app/controllers/api/audience/dashboards_controller.rb +++ b/portal/app/controllers/api/audience/dashboards_controller.rb @@ -4,7 +4,7 @@ class Api::Audience::DashboardsController < Api::Audience::ApplicationController pb :show, Isuxportal::Proto::Services::Audience::DashboardQuery def show expires_in 5.seconds, public: true, 's-maxage' => '10' - final = Rails.application.config.x.final ? "final" : "qualify" + final = Rails.application.config.x.contest.final ? "final" : "qualify" render protobuf: Rails.cache.read("dashboard:#{final}:audience:public") || Isuxportal::Proto::Services::Audience::DashboardResponse.new( leaderboard: Contest.leaderboard(admin: false, team: nil), # TODO: disable progresses ) diff --git a/portal/app/controllers/api/contestant/dashboards_controller.rb b/portal/app/controllers/api/contestant/dashboards_controller.rb index 3f0656e2..396b5bbf 100644 --- a/portal/app/controllers/api/contestant/dashboards_controller.rb +++ b/portal/app/controllers/api/contestant/dashboards_controller.rb @@ -4,7 +4,7 @@ class Api::Contestant::DashboardsController < Api::Contestant::ApplicationContro pb :show, Isuxportal::Proto::Services::Contestant::DashboardQuery def show # See also: UpdateContestantDashboardJob - final = Rails.application.config.x.final ? "final" : "qualify" + final = Rails.application.config.x.contest.final ? "final" : "qualify" ptr = Rails.cache.read("dashboard:#{final}:contestant:contestant-ptr:team-#{current_team.id}") || "dashboard:#{final}:contestant:public" if ptr && ptr.start_with?("dashboard:#{final}:contestant:") ptr_resp = Rails.cache.read(ptr) diff --git a/portal/app/jobs/update_contestant_dashboard_job.rb b/portal/app/jobs/update_contestant_dashboard_job.rb index 402d4921..73f73172 100644 --- a/portal/app/jobs/update_contestant_dashboard_job.rb +++ b/portal/app/jobs/update_contestant_dashboard_job.rb @@ -4,7 +4,7 @@ class UpdateContestantDashboardJob < ApplicationJob def perform(team: nil, frozen: false) - final = Rails.application.config.x.final ? "final" : "qualify" + final = Rails.application.config.x.contest.final ? "final" : "qualify" Rails.logger.info("leaderboard") lb = Contest.leaderboard(admin: false, team: nil, progresses: false)