Class: Dbwatcher::Services::TableStatisticsCollector
- Inherits:
-
Object
- Object
- Dbwatcher::Services::TableStatisticsCollector
- Includes:
- Logging
- Defined in:
- lib/dbwatcher/services/table_statistics_collector.rb
Overview
Service object for collecting and organizing table statistics Follows the command pattern with self.call class method
Class Method Summary collapse
-
.call ⇒ Array<Hash>
Sorted array of table statistics.
Instance Method Summary collapse
Methods included from Logging
#debug_enabled?, #log_debug, #log_error, #log_info, #log_warn
Class Method Details
.call ⇒ Array<Hash>
Returns sorted array of table statistics.
11 12 13 |
# File 'lib/dbwatcher/services/table_statistics_collector.rb', line 11 def self.call new.call end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dbwatcher/services/table_statistics_collector.rb', line 15 def call log_info "Starting table statistics collection" start_time = Time.current tables = build_initial_tables_hash populate_change_statistics(tables) result = sort_by_change_count(tables) duration = Time.current - start_time log_info "Completed table statistics collection in #{duration.round(3)}s", { tables_count: result.length, total_changes: result.sum { |t| t[:change_count] } } result end |