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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d38a7931c85980d77ac00274e9fd20d0aeeccea9968fcdce682e094c2fa8859
4
- data.tar.gz: 46ace0d92f363030da888b4fc3c0b81ba3429d6d46be11ed884e87cf953d982e
3
+ metadata.gz: 202029a129c23bfda08834a7867975d0e985789e516dcccd24391e9798ef1f63
4
+ data.tar.gz: 6f72d9f5affa0bd332a2e14d1c609e46741ae87cbabcc70086ce6263d4c3954e
5
5
  SHA512:
6
- metadata.gz: 72dc38b44223c63b08cf4a3021f53d96dca26c91a00447a92c9434f012add4f2693d02217fcbcc3d5a1a7117584ecab9b5248880a1510220ec24879591ec8b46
7
- data.tar.gz: 54bfd327be06ff7b2032fbd937e5bd9f1b1ee32042349d58a34efe4025ffcc650e4d219586c0afd116cb21113ca28b3cb43d07d9e2fe8bbf85f717935d648770
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
- Built by [Mezbah Alam](https://github.com/mezbahalam) Inspired by pg_hero and other database monitoring tools
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&nbsp;<span role="img" aria-label="love">❤️</span>&nbsp;by
292
+ <a href="https://github.com/mezbahalam"><strong>Mezbah Alam</strong></a>
293
+ </sub>
294
+ <br />
295
+ <sub>
296
+ Inspired by&nbsp;<a href="https://github.com/ankane/pghero"><strong>pg_hero</strong></a>
297
+ and other&nbsp;database-monitoring&nbsp;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
 
@@ -1,4 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PgInsights
2
4
  class ApplicationJob < ActiveJob::Base
5
+ queue_as do
6
+ PgInsights.background_job_queue
7
+ end
3
8
  end
4
9
  end
@@ -2,8 +2,6 @@
2
2
 
3
3
  module PgInsights
4
4
  class DatabaseSnapshotJob < ApplicationJob
5
- queue_as -> { PgInsights.background_job_queue }
6
-
7
5
  rescue_from(StandardError) do |exception|
8
6
  Rails.logger.error "PgInsights::DatabaseSnapshotJob failed: #{exception.message}"
9
7
  end
@@ -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
 
@@ -2,8 +2,6 @@
2
2
 
3
3
  module PgInsights
4
4
  class HealthCheckSchedulerJob < ApplicationJob
5
- queue_as -> { PgInsights.background_job_queue }
6
-
7
5
  rescue_from(StandardError) do |exception|
8
6
  Rails.logger.error "PgInsights::HealthCheckSchedulerJob failed: #{exception.message}"
9
7
  end
@@ -2,8 +2,6 @@
2
2
 
3
3
  module PgInsights
4
4
  class RecurringHealthChecksJob < ApplicationJob
5
- queue_as -> { PgInsights.background_job_queue }
6
-
7
5
  rescue_from(StandardError) do |exception|
8
6
  Rails.logger.error "PgInsights::RecurringHealthChecksJob failed: #{exception.message}"
9
7
  end
@@ -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: detect_parameter_changes_since(days)
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>
@@ -1,3 +1,3 @@
1
1
  module PgInsights
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.1"
3
3
  end
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.2.1
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-04 00:00:00.000000000 Z
11
+ date: 2025-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails