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:
27
backend/app/services/admin/dashboard_stats.rb
Normal file
27
backend/app/services/admin/dashboard_stats.rb
Normal 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
|
||||
Reference in New Issue
Block a user