Add ranking mode
Some checks failed
CI / scan_ruby (push) Successful in 20s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 12s
CI / test (push) Failing after 35s

This commit is contained in:
sto
2025-11-14 10:19:08 +01:00
parent cdf87e48f2
commit f91145637f
12 changed files with 51 additions and 38 deletions

View File

@@ -1,4 +1,6 @@
class ContestantsController < ApplicationController
include ContestantsConcern
before_action :set_contest
before_action :set_contestant, only: %i[ destroy edit update]
before_action :set_completions, only: %i[edit update ]
@@ -6,12 +8,7 @@ class ContestantsController < ApplicationController
def index
authorize @contest
@contestants = @contest.contestants.sort_by { |contestant| [
-contestant.completions.where(remaining_pieces: nil).size,
(contestant.completions.where(remaining_pieces: nil).size == @contest.puzzles.length ? 1 : 0) * contestant.time_seconds,
contestant.completions.size > 0 && contestant.completions[-1].remaining_pieces ? contestant.completions[-1].remaining_pieces : 1000000,
contestant.time_seconds
] }
@contestants = @contest.contestants.sort_by { |contestant| contestant.name }
filter_contestants_per_category
end
@@ -111,12 +108,7 @@ class ContestantsController < ApplicationController
def export
authorize @contest
@contestants = @contest.contestants.sort_by { |contestant| [
-contestant.completions.where(remaining_pieces: nil).size,
(contestant.completions.where(remaining_pieces: nil).size == @contest.puzzles.length ? 1 : 0) * contestant.time_seconds,
contestant.completions.size > 0 && contestant.completions[-1].remaining_pieces ? contestant.completions[-1].remaining_pieces : 1000000,
contestant.time_seconds
] }
@contestants = ranked_contestants(@contest)
respond_to do |format|
format.csv do