Files
MatchLiveTv/backend/app/services/tournaments/capture_stream_result.rb
T

36 lines
819 B
Ruby

module Tournaments
class CaptureStreamResult
def self.call(session)
new(session).call
end
def initialize(session)
@session = session
end
def call
match = @session.match
return unless match&.tournament_match?
score = @session.score_state
return unless score
board = match.effective_board_type
home, away, extra = case board
when "basket", "timed"
[score.basket_home_score, score.basket_away_score, { "board" => board }]
else
[score.home_sets, score.away_sets, { "board" => board, "partials" => score.set_partials }]
end
Tournaments::RecordResult.call(
match: match,
home_score: home,
away_score: away,
source: "stream",
result_data: extra
)
end
end
end