Files
MatchLiveTv/backend/app/controllers/public/team_pages_controller.rb
T
eminuxandCursor 1d97271555 Aggiunge i18n IT/EN/FR/DE/ES, pagine pubbliche squadre e UX archivio.
Il selettore lingua funziona sul web e sulle app native; su Android la preferenza è persistita e applicata al riavvio. Incluse anche eliminazione replay a scope e campi pagina pubblica squadra.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-23 19:30:44 +02:00

65 lines
1.8 KiB
Ruby

module Public
class TeamPagesController < SiteBaseController
include Public::LiveHelper
layout "marketing_live"
def index
@query = params[:q].to_s.strip
@sport = params[:sport].to_s.strip.presence
@live_filter = params[:live].present?
@replays_filter = params[:replays].present?
@entries = Teams::PublicDirectory.call(
q: @query,
sport: @sport,
live: @live_filter,
replays: @replays_filter
)
@sport_options = Sports::Catalog.as_api_list
end
def show
@team = Team.includes(:club, roster_members: []).find_by!(slug: params[:slug])
@club = @team.club
load_live_content!
end
private
def load_live_content!
@online_paths = fetch_online_paths
@live_sessions = StreamSession
.broadcasting
.publicly_listed
.where(platform: "matchlivetv")
.includes(:score_state, match: { team: :club })
.joins(:match)
.where(matches: { team_id: @team.id })
.order(Arel.sql("started_at DESC NULLS LAST"), created_at: :desc)
broadcasting_match_ids = StreamSession.broadcasting.select(:match_id)
@upcoming_matches = @team.matches
.scheduled_for_live
.where.not(id: broadcasting_match_ids)
.order(scheduled_at: :asc)
.limit(20)
@recordings = @team.recordings
.ready
.publicly_listed
.includes(stream_session: :match)
.order(recorded_at: :desc, created_at: :desc)
.limit(12)
@roster_by_category = @team.roster_public? ? @team.roster_by_category : nil
end
def fetch_online_paths
Mediamtx::Client.new.online_path_names
rescue Mediamtx::Client::Error, Errno::ECONNREFUSED, SocketError
[]
end
end
end