Lascia trasmissibili le partite anche dopo l'orario previsto.

Se l'operatore è in ritardo deve ancora trovare la gara nell'app: restano in hub per tutta la giornata e, nei tornei aperti, fino alla fine dell'evento.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-06 10:07:23 +02:00
co-authored by Cursor
parent c3ef8e91a6
commit 24c6ce4da0
10 changed files with 91 additions and 14 deletions
@@ -10,7 +10,7 @@ module Api
def index
matches = @team.matches
.includes(:team, :stream_sessions, :home_participant, :away_participant)
.includes(:team, :stream_sessions, :home_participant, :away_participant, :tournament)
.order(Arel.sql("scheduled_at ASC NULLS LAST"), created_at: :desc)
unless current_user.club_admin?(@team.club)
if @team.tournament_broadcast?
+10 -2
View File
@@ -98,10 +98,18 @@ class Match < ApplicationRecord
active = active_stream_session
return true if active&.resumable?
return true if active&.idle?
return false if stream_completed?
return true if scheduled_on_calendar?
return true if tournament_open_for_late_stream?
scheduled_upcoming?
false
end
def tournament_open_for_late_stream?
return false unless tournament_match?
event = tournament
event.present? && !event.archived? && event.ends_on >= Date.current
end
def effective_board_type
+38 -2
View File
@@ -83,15 +83,51 @@ RSpec.describe Match, "scheduling scopes" do
expect(match.coach_hub_visible?).to be(false)
end
it "nasconde partita programmata nel passato mai trasmessa" do
it "mostra partita di oggi già passata d'orario se non è stata trasmessa" do
match = team.matches.create!(
opponent_name: "Missed",
opponent_name: "Late",
scheduled_at: 2.hours.ago,
sets_to_win: 3
)
expect(match.coach_hub_visible?).to be(true)
end
it "nasconde partita di un giorno precedente mai trasmessa" do
match = team.matches.create!(
opponent_name: "Yesterday",
scheduled_at: 1.day.ago.change(hour: 10),
sets_to_win: 3
)
expect(match.coach_hub_visible?).to be(false)
end
it "mostra gara di torneo in corso anche se l'orario era ieri" do
broadcast = club.teams.create!(
name: "Torneo Late",
sport_key: "pallavolo",
internal_kind: Tournament::INTERNAL_TEAM_KIND
)
tournament = Tournament.create!(
club: club,
name: "Torneo Late",
sport_key: "pallavolo",
starts_on: Date.yesterday,
ends_on: Date.current,
format_kind: "free",
status: "published",
broadcast_team: broadcast
)
match = broadcast.matches.create!(
opponent_name: "TBD",
scheduled_at: 1.day.ago.change(hour: 10),
sets_to_win: 3,
tournament: tournament
)
expect(match.coach_hub_visible?).to be(true)
end
end
describe "scoring_rules" do