Initial commit: monorepo Match Live TV.
Rails API, app Flutter, infrastruttura Docker/MediaMTX, sito marketing e documentazione di deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
35
backend/app/helpers/public/live_helper.rb
Normal file
35
backend/app/helpers/public/live_helper.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
module Public
|
||||
module LiveHelper
|
||||
def live_score_sets_label(score_state)
|
||||
return nil unless score_state
|
||||
|
||||
"Set #{score_state.current_set} · Set vinti #{score_state.home_sets}-#{score_state.away_sets}"
|
||||
end
|
||||
|
||||
def live_score_partials_label(score_state)
|
||||
return nil unless score_state
|
||||
|
||||
partials = Array(score_state.set_partials)
|
||||
return nil if partials.empty?
|
||||
|
||||
partials.map { |p| format_set_partial_entry(p) }.join(" · ")
|
||||
end
|
||||
|
||||
def live_score_points_label(match, score_state)
|
||||
return "—" unless score_state
|
||||
|
||||
"#{match.team.name} #{score_state.home_points} - #{score_state.away_points} #{match.opponent_name}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def format_set_partial_entry(partial)
|
||||
data = partial.respond_to?(:with_indifferent_access) ? partial.with_indifferent_access : partial
|
||||
set_no = data[:set] || data["set"]
|
||||
home = data[:home] || data["home"]
|
||||
away = data[:away] || data["away"]
|
||||
label = set_no.present? ? "Set #{set_no}" : "Set"
|
||||
"#{label} #{home}-#{away}"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user