Aggiunge i tornei con hub, pagina pubblica e tabellone per semifinali e finali.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-05 15:05:57 +02:00
co-authored by Cursor
parent d52434fb2e
commit a1f4c24a43
124 changed files with 6979 additions and 91 deletions
@@ -0,0 +1,58 @@
module Tournaments
class RecordResult
def self.call(match:, home_score:, away_score:, source: "manual", result_data: {}, walkover: nil)
new(
match: match,
home_score: home_score,
away_score: away_score,
source: source,
result_data: result_data,
walkover: walkover
).call
end
def initialize(match:, home_score:, away_score:, source:, result_data:, walkover:)
@match = match
@home_score = home_score
@away_score = away_score
@source = source
@result_data = result_data || {}
@walkover = walkover
end
def call
return @match unless @match.tournament_match?
status = "played"
winner_id = nil
if @walkover == "home"
status = "walkover_home"
winner_id = @match.home_participant_id
@home_score = @home_score.presence || 1
@away_score = 0
elsif @walkover == "away"
status = "walkover_away"
winner_id = @match.away_participant_id
@away_score = @away_score.presence || 1
@home_score = 0
else
winner_id = if @home_score.to_i > @away_score.to_i
@match.home_participant_id
elsif @away_score.to_i > @home_score.to_i
@match.away_participant_id
end
end
@match.update!(
home_score: @home_score,
away_score: @away_score,
result_status: status,
result_source: @source,
result_data: @result_data,
winner_participant_id: winner_id
)
Tournaments::FillKnockoutSources.call(@match.tournament)
@match
end
end
end