Aggiunge gestione archivio replay nel pannello admin.
Gli admin possono vedere, modificare ed eliminare i replay di una società come la squadra proprietaria, riusando la stessa UI e logica dell'archivio pubblico. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
55
backend/app/services/recordings/club_archive.rb
Normal file
55
backend/app/services/recordings/club_archive.rb
Normal file
@@ -0,0 +1,55 @@
|
||||
module Recordings
|
||||
class ClubArchive
|
||||
def initialize(club, params: {})
|
||||
@club = club
|
||||
@params = params
|
||||
end
|
||||
|
||||
def stats
|
||||
Recordings::ClubStats.new(@club).call
|
||||
end
|
||||
|
||||
def teams
|
||||
@club.teams.order(:name)
|
||||
end
|
||||
|
||||
def filter_team_id
|
||||
@params[:team_id]
|
||||
end
|
||||
|
||||
def filter_status
|
||||
@params[:status]
|
||||
end
|
||||
|
||||
def recordings
|
||||
scope = Recording.for_club(@club)
|
||||
.not_deleted
|
||||
.includes(stream_session: { match: :team })
|
||||
.order(recorded_at: :desc, created_at: :desc)
|
||||
scope = scope.where(team_id: filter_team_id) if filter_team_id.present?
|
||||
apply_status_filter(scope)
|
||||
end
|
||||
|
||||
def filter_params
|
||||
{ team_id: filter_team_id, status: filter_status }.compact
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def apply_status_filter(scope)
|
||||
case filter_status
|
||||
when "ready"
|
||||
scope.ready
|
||||
when "processing"
|
||||
scope.where(status: "processing")
|
||||
when "expired"
|
||||
scope.where(
|
||||
"recordings.status IN (?) OR (recordings.expires_at IS NOT NULL AND recordings.expires_at <= ?)",
|
||||
%w[expired failed], Time.current
|
||||
)
|
||||
else
|
||||
scope
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user