Auto refresh feature on public scoreboards
All checks were successful
CI / scan_ruby (push) Successful in 19s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 13s
CI / test (push) Successful in 38s

#12
#13
This commit is contained in:
sto
2025-12-08 17:11:47 +01:00
parent 1fc05bea63
commit ee250b96ad
8 changed files with 89 additions and 56 deletions

View File

@@ -123,20 +123,19 @@ class ContestsController < ApplicationController
@title = I18n.t("contests.scoreboard.title", name: @contest.name)
@contestants = ranked_contestants(@contest)
filter_contestants_per_category
if params.key?(:category)
@category = params[:category]
filter_contestants_per_category
end
if params.key?(:hide_offline) && params[:hide_offline] == "true"
@contestants = @contestants.select { |contestant| !contestant.offline.present? }
@hide_offline = true
end
if params.key?(:autorefresh)
@autorefresh = true
end
@puzzles = @contest.puzzles.where(hidden: false).or(@contest.puzzles.where(hidden: nil)).order(:id)
if params.key?(:hide_offline) && params.key?(:category)
@action_path = "/public/#{@contest.friendly_id}?hide_offline=#{params[:hide_offline]}&category=#{params[:category]}"
elsif params.key?(:category)
@action_path = "/public/#{@contest.friendly_id}?category=#{params[:category]}"
elsif params.key?(:hide_offline)
@action_path = "/public/#{@contest.friendly_id}?hide_offline=#{params[:hide_offline]}"
else
@action_path = "/public/#{@contest.friendly_id}"
end
@action_path = "/public/#{@contest.friendly_id}"
@space = " "
render :scoreboard
end
@@ -254,11 +253,11 @@ class ContestsController < ApplicationController
end
def filter_contestants_per_category
if params.key?(:category) && params[:category] != "-1"
if params[:category] == "-2"
if @category != "-1"
if @category == "-2"
@contestants = @contestants.select { |contestant| contestant.categories.size == 0 }
else
@contestants = @contestants.select { |contestant| contestant.categories.where(id: params[:category]).any? }
@contestants = @contestants.select { |contestant| contestant.categories.where(id: @category).any? }
end
end
end