rails_pulse 0.2.2 → 0.2.4

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/stylesheets/rails_pulse/components/tags.css +2 -2
  4. data/app/controllers/concerns/chart_table_concern.rb +4 -3
  5. data/app/controllers/rails_pulse/application_controller.rb +11 -3
  6. data/app/controllers/rails_pulse/dashboard_controller.rb +12 -8
  7. data/app/controllers/rails_pulse/queries_controller.rb +13 -8
  8. data/app/controllers/rails_pulse/requests_controller.rb +10 -5
  9. data/app/controllers/rails_pulse/routes_controller.rb +14 -7
  10. data/app/helpers/rails_pulse/application_helper.rb +47 -2
  11. data/app/helpers/rails_pulse/chart_helper.rb +32 -2
  12. data/app/javascript/rails_pulse/application.js +3 -54
  13. data/app/javascript/rails_pulse/controllers/chart_controller.js +229 -0
  14. data/app/javascript/rails_pulse/controllers/index_controller.js +9 -14
  15. data/app/javascript/rails_pulse/controllers/pagination_controller.js +27 -33
  16. data/app/jobs/rails_pulse/backfill_summaries_job.rb +0 -2
  17. data/app/jobs/rails_pulse/cleanup_job.rb +0 -2
  18. data/app/jobs/rails_pulse/summary_job.rb +0 -2
  19. data/app/models/concerns/rails_pulse/taggable.rb +63 -0
  20. data/app/models/rails_pulse/dashboard/charts/average_response_time.rb +12 -5
  21. data/app/models/rails_pulse/dashboard/charts/p95_response_time.rb +12 -5
  22. data/app/models/rails_pulse/dashboard/tables/slow_queries.rb +7 -0
  23. data/app/models/rails_pulse/dashboard/tables/slow_routes.rb +6 -0
  24. data/app/models/rails_pulse/queries/cards/average_query_times.rb +10 -6
  25. data/app/models/rails_pulse/queries/cards/execution_rate.rb +16 -10
  26. data/app/models/rails_pulse/queries/cards/percentile_query_times.rb +10 -6
  27. data/app/models/rails_pulse/queries/charts/average_query_times.rb +6 -3
  28. data/app/models/rails_pulse/queries/tables/index.rb +12 -2
  29. data/app/models/rails_pulse/requests/charts/average_response_times.rb +13 -7
  30. data/app/models/rails_pulse/routes/cards/average_response_times.rb +10 -6
  31. data/app/models/rails_pulse/routes/cards/error_rate_per_route.rb +10 -6
  32. data/app/models/rails_pulse/routes/cards/percentile_response_times.rb +10 -6
  33. data/app/models/rails_pulse/routes/cards/request_count_totals.rb +10 -6
  34. data/app/models/rails_pulse/routes/charts/average_response_times.rb +10 -6
  35. data/app/models/rails_pulse/routes/tables/index.rb +12 -2
  36. data/app/models/rails_pulse/summary.rb +55 -0
  37. data/app/views/layouts/rails_pulse/_global_filters.html.erb +9 -2
  38. data/app/views/rails_pulse/components/_active_filters.html.erb +36 -0
  39. data/app/views/rails_pulse/components/_metric_card.html.erb +2 -2
  40. data/app/views/rails_pulse/components/_page_header.html.erb +4 -0
  41. data/app/views/rails_pulse/components/_sparkline_stats.html.erb +1 -1
  42. data/app/views/rails_pulse/components/_table_pagination.html.erb +8 -6
  43. data/app/views/rails_pulse/csp_test/show.html.erb +1 -1
  44. data/app/views/rails_pulse/dashboard/charts/_bar_chart.html.erb +1 -1
  45. data/app/views/rails_pulse/dashboard/index.html.erb +8 -3
  46. data/app/views/rails_pulse/queries/index.html.erb +3 -2
  47. data/app/views/rails_pulse/queries/show.html.erb +2 -1
  48. data/app/views/rails_pulse/requests/index.html.erb +1 -1
  49. data/app/views/rails_pulse/routes/index.html.erb +3 -2
  50. data/app/views/rails_pulse/routes/show.html.erb +2 -1
  51. data/app/views/rails_pulse/tags/_tag_manager.html.erb +2 -2
  52. data/config/importmap.rb +1 -1
  53. data/lib/rails_pulse/cleanup_service.rb +8 -0
  54. data/lib/rails_pulse/engine.rb +0 -5
  55. data/lib/rails_pulse/version.rb +1 -1
  56. data/public/rails-pulse-assets/csp-test.js +10 -10
  57. data/public/rails-pulse-assets/rails-pulse.css +1 -1
  58. data/public/rails-pulse-assets/rails-pulse.css.map +1 -1
  59. data/public/rails-pulse-assets/rails-pulse.js +48 -48
  60. data/public/rails-pulse-assets/rails-pulse.js.map +4 -4
  61. metadata +7 -26
  62. data/app/models/concerns/taggable.rb +0 -61
  63. data/config/initializers/rails_charts_csp_patch.rb +0 -75
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_pulse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rails Pulse
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-19 00:00:00.000000000 Z
10
+ date: 2025-11-05 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -49,26 +49,6 @@ dependencies:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
51
  version: 1.1.4
52
- - !ruby/object:Gem::Dependency
53
- name: rails_charts
54
- requirement: !ruby/object:Gem::Requirement
55
- requirements:
56
- - - "~>"
57
- - !ruby/object:Gem::Version
58
- version: '0.0'
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: 0.0.6
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.0'
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: 0.0.6
72
52
  - !ruby/object:Gem::Dependency
73
53
  name: turbo-rails
74
54
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +100,7 @@ dependencies:
120
100
  version: '8'
121
101
  - - "<"
122
102
  - !ruby/object:Gem::Version
123
- version: '10'
103
+ version: '44'
124
104
  type: :runtime
125
105
  prerelease: false
126
106
  version_requirements: !ruby/object:Gem::Requirement
@@ -130,7 +110,7 @@ dependencies:
130
110
  version: '8'
131
111
  - - "<"
132
112
  - !ruby/object:Gem::Version
133
- version: '10'
113
+ version: '44'
134
114
  - !ruby/object:Gem::Dependency
135
115
  name: groupdate
136
116
  requirement: !ruby/object:Gem::Requirement
@@ -225,6 +205,7 @@ files:
225
205
  - app/helpers/rails_pulse/table_helper.rb
226
206
  - app/helpers/rails_pulse/tags_helper.rb
227
207
  - app/javascript/rails_pulse/application.js
208
+ - app/javascript/rails_pulse/controllers/chart_controller.js
228
209
  - app/javascript/rails_pulse/controllers/collapsible_controller.js
229
210
  - app/javascript/rails_pulse/controllers/color_scheme_controller.js
230
211
  - app/javascript/rails_pulse/controllers/context_menu_controller.js
@@ -247,7 +228,7 @@ files:
247
228
  - app/jobs/rails_pulse/cleanup_job.rb
248
229
  - app/jobs/rails_pulse/summary_job.rb
249
230
  - app/mailers/rails_pulse/application_mailer.rb
250
- - app/models/concerns/taggable.rb
231
+ - app/models/concerns/rails_pulse/taggable.rb
251
232
  - app/models/rails_pulse/application_record.rb
252
233
  - app/models/rails_pulse/dashboard/charts/average_response_time.rb
253
234
  - app/models/rails_pulse/dashboard/charts/p95_response_time.rb
@@ -286,6 +267,7 @@ files:
286
267
  - app/views/layouts/rails_pulse/_menu_items.html.erb
287
268
  - app/views/layouts/rails_pulse/_sidebar_menu.html.erb
288
269
  - app/views/layouts/rails_pulse/application.html.erb
270
+ - app/views/rails_pulse/components/_active_filters.html.erb
289
271
  - app/views/rails_pulse/components/_code_panel.html.erb
290
272
  - app/views/rails_pulse/components/_empty_state.html.erb
291
273
  - app/views/rails_pulse/components/_metric_card.html.erb
@@ -331,7 +313,6 @@ files:
331
313
  - app/views/rails_pulse/skeletons/_table.html.erb
332
314
  - app/views/rails_pulse/tags/_tag_manager.html.erb
333
315
  - config/importmap.rb
334
- - config/initializers/rails_charts_csp_patch.rb
335
316
  - config/initializers/rails_pulse.rb
336
317
  - config/routes.rb
337
318
  - db/migrate/20250930105043_install_rails_pulse_tables.rb
@@ -1,61 +0,0 @@
1
- module Taggable
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- # Callbacks
6
- before_save :ensure_tags_is_array
7
-
8
- # Scopes with table name qualification to avoid ambiguity
9
- scope :with_tag, ->(tag) { where("#{table_name}.tags LIKE ?", "%#{tag}%") }
10
- scope :without_tag, ->(tag) { where.not("#{table_name}.tags LIKE ?", "%#{tag}%") }
11
- scope :with_tags, -> { where("#{table_name}.tags IS NOT NULL AND #{table_name}.tags != '[]'") }
12
- end
13
-
14
- # Tag management methods
15
- def tag_list
16
- parsed_tags || []
17
- end
18
-
19
- def tag_list=(value)
20
- self.tags = value.to_json
21
- end
22
-
23
- def has_tag?(tag)
24
- tag_list.include?(tag.to_s)
25
- end
26
-
27
- def add_tag(tag)
28
- current_tags = tag_list
29
- unless current_tags.include?(tag.to_s)
30
- current_tags << tag.to_s
31
- self.tag_list = current_tags
32
- save
33
- end
34
- end
35
-
36
- def remove_tag(tag)
37
- current_tags = tag_list
38
- if current_tags.include?(tag.to_s)
39
- current_tags.delete(tag.to_s)
40
- self.tag_list = current_tags
41
- save
42
- end
43
- end
44
-
45
- private
46
-
47
- def parsed_tags
48
- return [] if tags.nil? || tags.empty?
49
- JSON.parse(tags)
50
- rescue JSON::ParserError
51
- []
52
- end
53
-
54
- def ensure_tags_is_array
55
- if tags.nil?
56
- self.tags = "[]"
57
- elsif tags.is_a?(Array)
58
- self.tags = tags.to_json
59
- end
60
- end
61
- end
@@ -1,75 +0,0 @@
1
- # CSP patch for RailsCharts gem
2
- # Adds nonce attributes to script tags generated by RailsCharts for CSP compliance
3
-
4
- if defined?(RailsCharts)
5
- module RailsCharts
6
- module CspPatch
7
- def line_chart(data_source, options = {})
8
- chart_html = super(data_source, options)
9
- add_csp_nonce_to_chart(chart_html)
10
- end
11
-
12
- def bar_chart(data_source, options = {})
13
- chart_html = super(data_source, options)
14
- add_csp_nonce_to_chart(chart_html)
15
- end
16
-
17
- private
18
-
19
- def add_csp_nonce_to_chart(chart_html)
20
- return chart_html unless chart_html.present?
21
-
22
- nonce = get_csp_nonce
23
- return chart_html unless nonce.present?
24
-
25
- # Add nonce to script tags and mark as safe
26
- modified_html = add_nonce_to_scripts(chart_html.to_s, nonce)
27
- modified_html.html_safe if modified_html.respond_to?(:html_safe)
28
- end
29
-
30
- def get_csp_nonce
31
- # Try common CSP nonce sources in order of preference
32
- if respond_to?(:content_security_policy_nonce)
33
- content_security_policy_nonce
34
- elsif respond_to?(:csp_nonce)
35
- csp_nonce
36
- elsif defined?(request) && request
37
- request.env["action_dispatch.content_security_policy_nonce"] ||
38
- request.env["secure_headers.content_security_policy_nonce"] ||
39
- request.env["csp_nonce"]
40
- elsif respond_to?(:controller) && controller.respond_to?(:content_security_policy_nonce)
41
- controller.content_security_policy_nonce
42
- elsif defined?(@view_context) && @view_context.respond_to?(:content_security_policy_nonce)
43
- @view_context.content_security_policy_nonce
44
- else
45
- Thread.current[:rails_pulse_csp_nonce] ||
46
- (defined?(RequestStore) && RequestStore.store[:rails_pulse_csp_nonce])
47
- end
48
- end
49
-
50
- def add_nonce_to_scripts(html, nonce)
51
- html.gsub(/<script(?![^>]*\snonce=)([^>]*)>/i) do |match|
52
- attributes = $1
53
- if attributes.strip.empty?
54
- "<script nonce=\"#{nonce}\">"
55
- else
56
- "<script#{attributes} nonce=\"#{nonce}\">"
57
- end
58
- end
59
- end
60
- end
61
- end
62
- end
63
-
64
- # Apply the patch to ApplicationHelper and any modules that include chart helpers
65
- Rails.application.config.to_prepare do
66
- if defined?(RailsCharts)
67
- # Patch ActionView::Base to include our CSP patch for line_chart
68
- ActionView::Base.prepend(RailsCharts::CspPatch)
69
-
70
- # Also patch any Rails Pulse helpers that might use charts
71
- if defined?(RailsPulse::ApplicationHelper)
72
- RailsPulse::ApplicationHelper.prepend(RailsCharts::CspPatch)
73
- end
74
- end
75
- end