Module: PgReports
- Defined in:
- lib/pg_reports.rb,
lib/pg_reports/error.rb,
lib/pg_reports/engine.rb,
lib/pg_reports/filter.rb,
lib/pg_reports/report.rb,
lib/pg_reports/version.rb,
lib/pg_reports/executor.rb,
lib/pg_reports/sql_loader.rb,
lib/pg_reports/compatibility.rb,
lib/pg_reports/configuration.rb,
lib/pg_reports/query_monitor.rb,
lib/pg_reports/report_loader.rb,
lib/pg_reports/modules/system.rb,
lib/pg_reports/modules/tables.rb,
lib/pg_reports/modules/indexes.rb,
lib/pg_reports/modules/queries.rb,
lib/pg_reports/telegram_sender.rb,
lib/pg_reports/explain_analyzer.rb,
lib/pg_reports/module_generator.rb,
lib/pg_reports/annotation_parser.rb,
lib/pg_reports/report_definition.rb,
lib/pg_reports/modules/connections.rb,
lib/pg_reports/modules/schema_analysis.rb,
lib/pg_reports/dashboard/reports_registry.rb,
app/controllers/pg_reports/dashboard_controller.rb
Defined Under Namespace
Modules: AnnotationParser, Compatibility, Dashboard, Modules, SqlLoader, TelegramSender
Classes: Configuration, ConnectionError, DashboardController, Engine, Error, Executor, ExplainAnalyzer, Filter, ModuleGenerator, QueryMonitor, Report, ReportDefinition, ReportLoader, SqlFileNotFoundError, TelegramNotConfiguredError
Constant Summary
collapse
- VERSION =
"0.6.1"
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
110
111
112
|
# File 'lib/pg_reports/configuration.rb', line 110
def config
configuration
end
|
.configuration ⇒ Object
102
103
104
|
# File 'lib/pg_reports/configuration.rb', line 102
def configuration
@configuration ||= Configuration.new
end
|
106
107
108
|
# File 'lib/pg_reports/configuration.rb', line 106
def configure
yield(configuration)
end
|
.health_report ⇒ Report
Generate a comprehensive database health report
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/pg_reports.rb', line 75
def health_report
reports = {
"Slow Queries" => slow_queries(limit: 10),
"Expensive Queries" => expensive_queries(limit: 10),
"Unused Indexes" => unused_indexes(limit: 10),
"Tables Needing Vacuum" => vacuum_needed(limit: 10),
"Long Running Queries" => long_running_queries,
"Blocking Queries" => blocking_queries
}
combined_data = reports.map do |name, report|
{
"section" => name,
"items_count" => report.size,
"has_issues" => report.size.positive?
}
end
Report.new(
title: "Database Health Report",
data: combined_data,
columns: %w[section items_count has_issues]
)
end
|
.indexes ⇒ Object
112
113
114
|
# File 'lib/pg_reports.rb', line 112
def indexes
Modules::Indexes
end
|
.queries ⇒ Object
Shorthand for accessing modules directly
108
109
110
|
# File 'lib/pg_reports.rb', line 108
def queries
Modules::Queries
end
|
.reload_definitions! ⇒ Object
Reload YAML report definitions and regenerate module methods
.reset_configuration! ⇒ Object
114
115
116
|
# File 'lib/pg_reports/configuration.rb', line 114
def reset_configuration!
@configuration = Configuration.new
end
|
.schema_analysis ⇒ Object
.send_health_report_to_telegram ⇒ Object
Run all reports and send summary to Telegram
103
104
105
|
# File 'lib/pg_reports.rb', line 103
def send_health_report_to_telegram
health_report.send_to_telegram
end
|
.system ⇒ Object
124
125
126
|
# File 'lib/pg_reports.rb', line 124
def system
Modules::System
end
|
.tables ⇒ Object
116
117
118
|
# File 'lib/pg_reports.rb', line 116
def tables
Modules::Tables
end
|