Class: Dbwatcher::Services::DashboardDataAggregator

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/dbwatcher/services/dashboard_data_aggregator.rb

Overview

Service object for aggregating dashboard statistics Provides recent sessions, active tables, and query metrics

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#debug_enabled?, #log_debug, #log_error, #log_info, #log_warn

Class Method Details

.callHash

Returns dashboard statistics with recent_sessions, active_tables, query_stats.

Returns:

  • (Hash)

    dashboard statistics with recent_sessions, active_tables, query_stats



11
12
13
# File 'lib/dbwatcher/services/dashboard_data_aggregator.rb', line 11

def self.call
  new.call
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dbwatcher/services/dashboard_data_aggregator.rb', line 15

def call
  log_info "Starting dashboard data aggregation"
  start_time = Time.current

  result = {
    recent_sessions: fetch_recent_sessions,
    active_tables: calculate_active_tables,
    query_stats: aggregate_query_statistics
  }

  duration = Time.current - start_time
  log_info "Completed dashboard aggregation in #{duration.round(3)}s", {
    recent_sessions_count: result[:recent_sessions].length,
    active_tables_count: result[:active_tables].length,
    total_queries: result[:query_stats][:total]
  }

  result
end