pg_insights 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +20 -2
- data/app/controllers/pg_insights/timeline_controller.rb +1 -1
- data/app/jobs/pg_insights/application_job.rb +5 -0
- data/app/jobs/pg_insights/database_snapshot_job.rb +0 -2
- data/app/jobs/pg_insights/health_check_job.rb +0 -6
- data/app/jobs/pg_insights/health_check_scheduler_job.rb +0 -2
- data/app/jobs/pg_insights/recurring_health_checks_job.rb +0 -2
- data/app/models/pg_insights/health_check_result.rb +6 -2
- data/app/views/layouts/pg_insights/application.html.erb +4 -0
- data/lib/pg_insights/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 202029a129c23bfda08834a7867975d0e985789e516dcccd24391e9798ef1f63
|
4
|
+
data.tar.gz: 6f72d9f5affa0bd332a2e14d1c609e46741ae87cbabcc70086ce6263d4c3954e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a934c35cbd99830313711b601a0b50de06da05aa09d1cd7c49de42bf37d816e224333c13b27d92da623070caadb433ed844789f00d8080804d16a9d36c2ce15
|
7
|
+
data.tar.gz: 892adeea3391c59f4932bfd1aa789523cfe7390cd8b91401e356bc2ac3a0a15ac54084c4eb9fb2fa662c5939c73c73fcb904881addbb9473d41d8e946d8157c1
|
data/README.md
CHANGED
@@ -273,10 +273,28 @@ bundle exec rake spec
|
|
273
273
|
|
274
274
|
MIT License. See [LICENSE](MIT-LICENSE) file.
|
275
275
|
|
276
|
-
|
276
|
+
## 🙏 Special Thanks
|
277
277
|
|
278
278
|
<div align="center">
|
279
279
|
|
280
|
-
|
280
|
+
> *"Great mentors don't just teach you how to write code, they inspire you to build something meaningful."*
|
281
|
+
|
282
|
+
**Special thanks to [Keith Doggett](https://github.com/keithdoggett) ([@keithdoggett](https://github.com/keithdoggett))**
|
283
|
+
*Team Lead & Technical Mentor*
|
281
284
|
|
282
285
|
</div>
|
286
|
+
|
287
|
+
---
|
288
|
+
|
289
|
+
<p align="center">
|
290
|
+
<sub>
|
291
|
+
Built with <span role="img" aria-label="love">❤️</span> by
|
292
|
+
<a href="https://github.com/mezbahalam"><strong>Mezbah Alam</strong></a>
|
293
|
+
</sub>
|
294
|
+
<br />
|
295
|
+
<sub>
|
296
|
+
Inspired by <a href="https://github.com/ankane/pghero"><strong>pg_hero</strong></a>
|
297
|
+
and other database-monitoring tools
|
298
|
+
</sub>
|
299
|
+
</p>
|
300
|
+
|
@@ -13,7 +13,7 @@ module PgInsights
|
|
13
13
|
|
14
14
|
@snapshots = HealthCheckResult.snapshots(90)
|
15
15
|
@parameter_changes = HealthCheckResult.detect_parameter_changes_since(30)
|
16
|
-
@timeline_data = HealthCheckResult.timeline_data(30)
|
16
|
+
@timeline_data = HealthCheckResult.timeline_data(30, @parameter_changes)
|
17
17
|
@stats = calculate_timeline_stats(@snapshots)
|
18
18
|
end
|
19
19
|
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module PgInsights
|
4
4
|
class HealthCheckJob < ApplicationJob
|
5
|
-
queue_as -> { PgInsights.background_job_queue }
|
6
|
-
|
7
5
|
rescue_from(StandardError) do |exception|
|
8
6
|
Rails.logger.error "PgInsights::HealthCheckJob failed: #{exception.message}"
|
9
7
|
end
|
@@ -26,10 +24,6 @@ module PgInsights
|
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
def self.queue_name
|
30
|
-
PgInsights.background_job_queue
|
31
|
-
end
|
32
|
-
|
33
27
|
def self.perform_check(check_type, options = {})
|
34
28
|
return false unless PgInsights.background_jobs_available?
|
35
29
|
|
@@ -121,19 +121,23 @@ module PgInsights
|
|
121
121
|
deleted_count
|
122
122
|
end
|
123
123
|
|
124
|
-
def self.timeline_data(days = 30)
|
124
|
+
def self.timeline_data(days = 30, parameter_changes = nil)
|
125
125
|
snapshots = by_type("database_snapshot")
|
126
126
|
.successful
|
127
127
|
.where("executed_at >= ?", days.days.ago)
|
128
128
|
.order(:executed_at)
|
129
129
|
|
130
|
+
build_timeline_data(snapshots, parameter_changes || detect_parameter_changes_since(days))
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.build_timeline_data(snapshots, parameter_changes)
|
130
134
|
{
|
131
135
|
dates: snapshots.map { |s| s.executed_at.strftime("%Y-%m-%d %H:%M") },
|
132
136
|
cache_hit_rates: snapshots.map { |s| (s.result_data.dig("metrics", "cache_hit_rate") || 0).to_f },
|
133
137
|
avg_query_times: snapshots.map { |s| (s.result_data.dig("metrics", "avg_query_time") || 0).to_f },
|
134
138
|
bloated_tables: snapshots.map { |s| (s.result_data.dig("metrics", "bloated_tables") || 0).to_i },
|
135
139
|
total_connections: snapshots.map { |s| (s.result_data.dig("metrics", "total_connections") || 0).to_i },
|
136
|
-
parameter_changes:
|
140
|
+
parameter_changes: parameter_changes
|
137
141
|
}
|
138
142
|
end
|
139
143
|
|
@@ -7,7 +7,11 @@
|
|
7
7
|
<meta name="csrf-token" content="<%= form_authenticity_token %>">
|
8
8
|
<%#= favicon_link_tag "favicon.png" %>
|
9
9
|
<%= stylesheet_link_tag "pg_insights/application", media: "all" %>
|
10
|
+
<%= stylesheet_link_tag "pg_insights/results", media: "all" %>
|
11
|
+
<%= stylesheet_link_tag "pg_insights/health", media: "all" %>
|
10
12
|
<%= javascript_include_tag "pg_insights/application", nonce: true %>
|
13
|
+
<%= javascript_include_tag "pg_insights/results", nonce: true %>
|
14
|
+
<%= javascript_include_tag "pg_insights/health", nonce: true %>
|
11
15
|
|
12
16
|
</head>
|
13
17
|
<body>
|
data/lib/pg_insights/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_insights
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mezbah Alam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-07-
|
11
|
+
date: 2025-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|