Fix hub diretta: considera solo l'ultima sessione, non idle orfane.

Dopo «Termina trasmissione» la partita restava visibile se esisteva una vecchia sessione idle precedente a quella ended; l'hub e l'app usano ora lo stato dell'ultima sessione.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-09 21:58:01 +02:00
parent ad9d67ddb6
commit 01b7a3c96b
5 changed files with 31 additions and 9 deletions

View File

@@ -53,6 +53,27 @@ RSpec.describe Match, "scheduling scopes" do
expect(match.coach_hub_visible?).to be(false)
end
it "nasconde partita con diretta terminata anche se resta una sessione idle vecchia" do
match = team.matches.create!(opponent_name: "Avversario", sets_to_win: 3)
StreamSession.create!(
match: match,
user: user,
platform: "matchlivetv",
status: "idle",
created_at: 3.days.ago
)
StreamSession.create!(
match: match,
user: user,
platform: "matchlivetv",
status: "ended",
created_at: 1.hour.ago
)
expect(match.active_stream_session).to be_nil
expect(match.coach_hub_visible?).to be(false)
end
it "nasconde partita programmata nel passato mai trasmessa" do
match = team.matches.create!(
opponent_name: "Missed",