Files
MatchLiveTv/backend/app/services/admin/dashboard_stats.rb
Emiliano Frascaro 1f273f849d Aggiunge modulo Replay, Garage dev e YouTube a livello società.
Pipeline registrazione/upload con storage S3, archivio web e app, proxy replay
per il browser, OAuth YouTube sulla pagina club (Premium Full) e footer legale.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 07:53:11 +02:00

30 lines
1.1 KiB
Ruby

module Admin
class DashboardStats
ACTIVE_STATUSES = %w[live reconnecting connecting paused].freeze
def call
now = Time.current
day_start = now.beginning_of_day
month_start = now.beginning_of_month
ended_today = StreamSession.where(status: "ended").where("ended_at >= ?", day_start)
ended_month = StreamSession.where(status: "ended").where("ended_at >= ?", month_start)
{
active_sessions: StreamSession.where(status: ACTIVE_STATUSES).count,
sessions_today: ended_today.count,
sessions_month: ended_month.count,
stream_minutes_today: (ended_today.sum(:total_duration_secs).to_i / 60.0).round,
stream_minutes_month: (ended_month.sum(:total_duration_secs).to_i / 60.0).round,
teams_count: Team.count,
users_count: User.count,
matches_count: Match.count,
recordings_count: Recording.not_deleted.count,
recordings_ready: Recording.ready.count,
recordings_bytes: Recording.ready.sum(:byte_size).to_i,
recordings_expiring_soon: Recording.ready.expiring_within(7).count,
}
end
end
end