Admin protetto, dashboard KPI e aggiornamenti sito marketing.

Login admin con cambio password, metriche server (CPU/RAM/disco/banda), grafici e statistiche streaming; sezione piani ridimensionata.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-26 18:18:47 +02:00
parent 3d3420cc4a
commit 3a5649f482
26 changed files with 983 additions and 55 deletions

View File

@@ -0,0 +1,27 @@
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.count,
recordings_ready: Recording.where(status: "ready").count
}
end
end
end