Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/live_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def should_recompute?
end

def complete?
live_attempts.where.not(value: 0).count == round.format.expected_solve_count
live_attempts.filter { it.value != 0 }.length == round.format.expected_solve_count
end

def values_for_sorting
Expand Down
5 changes: 4 additions & 1 deletion app/models/round.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ def recompute_advancing

missing_attempts = total_competitors - round_results.count
potential_results = Array.new(missing_attempts) { LiveResult.build(round: self) }
results_with_potential = (round_results.to_a + potential_results).sort_by(&:potential_solve_time)

# Eager load associations to avoid N+1 on potential_solve_time
loaded_results = round_results.includes(:live_attempts).to_a
results_with_potential = (loaded_results + potential_results).sort_by(&:potential_solve_time)

qualifying_index = if final_round?
3
Expand Down