Nasconde dall'hub le partite con risultato già inserito.

Restano avviabili solo le gare in ritardo senza punteggio, non quelle già terminate dal portale.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-06 10:13:10 +02:00
co-authored by Cursor
parent 24c6ce4da0
commit ce81bb5789
5 changed files with 51 additions and 4 deletions
@@ -16,7 +16,7 @@ module Public
Tournaments::Entitlements.new(@club).assert_writable!
match = @tournament.matches.find(params[:match_id])
attrs = match_params
if match.played? || match.result_status.to_s.start_with?("walkover")
if match.result_recorded?
attrs = attrs.except(:home_participant_id, :away_participant_id)
end
match.update!(attrs)
@@ -100,7 +100,7 @@ module Public
def tournament_public_board_state(match)
return :live if tournament_public_live_session(match)
return :replay if tournament_public_recording(match)
return :ended if match.played? || match.result_status.to_s.start_with?("walkover") || match.home_score.present?
return :ended if match.result_recorded?
return :scheduled if match.scheduled_upcoming?
:waiting
@@ -129,7 +129,7 @@ module Public
end
def tournament_match_sides_locked?(match)
match.played? || match.result_status.to_s.start_with?("walkover")
match.result_recorded?
end
def tournament_phase_label(match)
+5
View File
@@ -94,10 +94,15 @@ class Match < ApplicationRecord
opponent_primary_color.presence || DEFAULT_OPPONENT_COLOR
end
def result_recorded?
played? || result_status.to_s.start_with?("walkover") || (home_score.present? && away_score.present?)
end
def coach_hub_visible?
active = active_stream_session
return true if active&.resumable?
return true if active&.idle?
return false if result_recorded?
return false if stream_completed?
return true if scheduled_on_calendar?
return true if tournament_open_for_late_stream?
@@ -51,7 +51,7 @@
</div>
<div class="tournament-match-row__score">
<span class="tournament-match-row__label"><%= t("tournaments.hub.result") %></span>
<% if match.played? || match.result_status.to_s.start_with?("walkover") %>
<% if match.result_recorded? %>
<p data-swap-played-score><%= match.home_score %><%= match.away_score %></p>
<% else %>
<span class="tournament-match-form__score">
@@ -83,6 +83,48 @@ RSpec.describe Match, "scheduling scopes" do
expect(match.coach_hub_visible?).to be(false)
end
it "nasconde partita con risultato inserito dal portale anche senza diretta" do
match = team.matches.create!(
opponent_name: "Squadra 4",
scheduled_at: 2.hours.ago,
sets_to_win: 3,
home_score: 11,
away_score: 10,
result_status: "played"
)
expect(match.coach_hub_visible?).to be(false)
end
it "nasconde walkover anche se il torneo è ancora aperto" do
broadcast = club.teams.create!(
name: "Torneo Walkover",
sport_key: "pallavolo",
internal_kind: Tournament::INTERNAL_TEAM_KIND
)
tournament = Tournament.create!(
club: club,
name: "Torneo Walkover",
sport_key: "pallavolo",
starts_on: Date.current,
ends_on: Date.current,
format_kind: "free",
status: "published",
broadcast_team: broadcast
)
match = broadcast.matches.create!(
opponent_name: "TBD",
scheduled_at: 1.hour.ago,
sets_to_win: 3,
tournament: tournament,
result_status: "walkover_home",
home_score: 1,
away_score: 0
)
expect(match.coach_hub_visible?).to be(false)
end
it "mostra partita di oggi già passata d'orario se non è stata trasmessa" do
match = team.matches.create!(
opponent_name: "Late",