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:
@@ -0,0 +1,34 @@
|
||||
module Tournaments
|
||||
class ScheduleMatch
|
||||
def self.call(tournament:, attrs:)
|
||||
new(tournament: tournament, attrs: attrs).call
|
||||
end
|
||||
|
||||
def initialize(tournament:, attrs:)
|
||||
@tournament = tournament
|
||||
@attrs = attrs.to_h.symbolize_keys
|
||||
end
|
||||
|
||||
def call
|
||||
Tournaments::Entitlements.new(@tournament.club).assert_writable!
|
||||
raise Tournaments::EntitlementError.new("Torneo archiviato", code: "archived") unless @tournament.writable?
|
||||
|
||||
team = Tournaments::EnsureBroadcastTeam.call(@tournament)
|
||||
match = team.matches.build(
|
||||
tournament: @tournament,
|
||||
sport_key: @tournament.sport_key,
|
||||
home_participant_id: @attrs[:home_participant_id].presence,
|
||||
away_participant_id: @attrs[:away_participant_id].presence,
|
||||
tournament_group_id: @attrs[:tournament_group_id].presence,
|
||||
tournament_round_id: @attrs[:tournament_round_id].presence,
|
||||
court: @attrs[:court].presence,
|
||||
location: @attrs[:location].presence,
|
||||
scheduled_at: @attrs[:scheduled_at],
|
||||
opponent_name: "TBD",
|
||||
sets_to_win: @attrs[:sets_to_win].presence || 3
|
||||
)
|
||||
match.save!
|
||||
match
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user