rails_pulse 0.1.0 → 0.1.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 +2 -2
- data/Rakefile +8 -181
- data/app/models/rails_pulse/dashboard/tables/slow_queries.rb +2 -2
- data/app/models/rails_pulse/dashboard/tables/slow_routes.rb +40 -21
- data/lib/rails_pulse/configuration.rb +6 -1
- data/lib/rails_pulse/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: 9a7e7efdfd91dc728f40f7f661b81f02633ae414963dcf6de1ceff81636033b5
|
4
|
+
data.tar.gz: 46a8441fd04bb5b771cc2107f0c7fb254e0400dcef824e7bd240980a605c7ba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8c5ce878786c71ef5d351f12881d6b3d93e940e090cec1843f65052aee58b084c396cbe61a00942704d534a5824274b24d7af4d033fb440a87a502137822867
|
7
|
+
data.tar.gz: 30ad722ade45a6e57220373e04a8f99c01d417969921aaf3c7bba463b3a29c345bca787587bbaf6f517d21b7cf37e39fee23dbc4edbcc3680b1762a16a7f77fb
|
data/README.md
CHANGED
@@ -632,7 +632,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
632
632
|
<div align="center">
|
633
633
|
<strong>Built with ❤️ for the Rails community</strong>
|
634
634
|
|
635
|
-
[Documentation](https://github.com/
|
636
|
-
[Issues](https://github.com/
|
635
|
+
[Documentation](https://github.com/railspulse/rails_pulse/wiki) •
|
636
|
+
[Issues](https://github.com/railspulse/rails_pulse/issues) •
|
637
637
|
[Contributing](CONTRIBUTING.md)
|
638
638
|
</div>
|
data/Rakefile
CHANGED
@@ -2,206 +2,33 @@ require "bundler/setup"
|
|
2
2
|
|
3
3
|
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
4
4
|
load "rails/tasks/engine.rake"
|
5
|
-
|
6
5
|
load "rails/tasks/statistics.rake"
|
7
6
|
|
8
7
|
require "bundler/gem_tasks"
|
9
8
|
|
10
9
|
# Test tasks
|
11
10
|
namespace :test do
|
12
|
-
desc "Run unit tests (
|
11
|
+
desc "Run unit tests (models, helpers, services)"
|
13
12
|
task :unit do
|
14
|
-
|
15
|
-
ENV["MEMORY_DATABASE"] = "true"
|
16
|
-
Rake::Task["test:run_unit"].invoke
|
13
|
+
sh "rails test test/models test/helpers test/services test/support"
|
17
14
|
end
|
18
15
|
|
19
|
-
desc "Run functional tests"
|
16
|
+
desc "Run functional tests (controllers)"
|
20
17
|
task :functional do
|
21
|
-
|
22
|
-
ENV["MEMORY_DATABASE"] = "true"
|
23
|
-
Rake::Task["test:run_functional"].invoke
|
18
|
+
sh "rails test test/controllers"
|
24
19
|
end
|
25
20
|
|
26
21
|
desc "Run integration tests"
|
27
22
|
task :integration do
|
28
|
-
|
29
|
-
ENV["MEMORY_DATABASE"] = "false"
|
30
|
-
Rake::Task["test:run_integration"].invoke
|
23
|
+
sh "rails test test/integration test/system"
|
31
24
|
end
|
32
25
|
|
33
|
-
desc "Run all tests
|
26
|
+
desc "Run all tests"
|
34
27
|
task :all do
|
35
|
-
|
36
|
-
puts "\n=== Running #{test_type} tests ==="
|
37
|
-
Rake::Task["test:#{test_type}"].invoke
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
desc "Run unit tests (alias for test:unit)"
|
42
|
-
task units: :unit
|
43
|
-
|
44
|
-
desc "Run functional tests (alias for test:functional)"
|
45
|
-
task functionals: :functional
|
46
|
-
|
47
|
-
desc "Run integration tests (alias for test:integration)"
|
48
|
-
task integrations: :integration
|
49
|
-
|
50
|
-
desc "Run tests with speed optimizations"
|
51
|
-
task fast: :unit
|
52
|
-
|
53
|
-
|
54
|
-
# Internal tasks
|
55
|
-
task :run_unit do
|
56
|
-
sh "rails test test/models test/middleware test/lib test/support"
|
57
|
-
end
|
58
|
-
|
59
|
-
task :run_functional do
|
60
|
-
sh "rails test test/controllers test/helpers"
|
61
|
-
end
|
62
|
-
|
63
|
-
task :run_integration do
|
64
|
-
sh "rails test test/integration"
|
28
|
+
sh "rails test"
|
65
29
|
end
|
66
30
|
end
|
67
31
|
|
68
|
-
#
|
69
|
-
desc "Run fast unit tests only"
|
70
|
-
task test_fast: "test:unit"
|
71
|
-
|
72
|
-
# Override default test task to run all tests
|
32
|
+
# Override default test task
|
73
33
|
desc "Run all tests"
|
74
34
|
task test: "test:all"
|
75
|
-
|
76
|
-
# Simplified database testing tasks
|
77
|
-
namespace :test do
|
78
|
-
desc "Run tests with SQLite (default)"
|
79
|
-
task :sqlite do
|
80
|
-
puts "🗂️ Testing with SQLite..."
|
81
|
-
Rake::Task["test:all"].invoke
|
82
|
-
end
|
83
|
-
|
84
|
-
desc "Run tests with PostgreSQL"
|
85
|
-
task :postgresql do
|
86
|
-
puts "🐘 Testing with PostgreSQL..."
|
87
|
-
env = ENV.to_h.merge(
|
88
|
-
"DATABASE_ADAPTER" => "postgresql",
|
89
|
-
"FORCE_DB_CONFIG" => "true"
|
90
|
-
)
|
91
|
-
system(env, "rails test:all") || raise("PostgreSQL tests failed")
|
92
|
-
end
|
93
|
-
|
94
|
-
desc "Run tests with MySQL"
|
95
|
-
task :mysql do
|
96
|
-
puts "🐬 Testing with MySQL..."
|
97
|
-
env = ENV.to_h.merge(
|
98
|
-
"DATABASE_ADAPTER" => "mysql2",
|
99
|
-
"FORCE_DB_CONFIG" => "true",
|
100
|
-
"PARALLEL_WORKERS" => "1"
|
101
|
-
)
|
102
|
-
system(env, "rails test:all") || raise("MySQL tests failed")
|
103
|
-
end
|
104
|
-
|
105
|
-
desc "Run test matrix (SQLite + PostgreSQL + MySQL)"
|
106
|
-
task :matrix do
|
107
|
-
puts "\n🧪 Running test matrix...\n"
|
108
|
-
|
109
|
-
databases = [
|
110
|
-
{ name: "SQLite", env: {}, emoji: "🗂️" },
|
111
|
-
{ name: "PostgreSQL", env: { "DATABASE_ADAPTER" => "postgresql", "FORCE_DB_CONFIG" => "true" }, emoji: "🐘" },
|
112
|
-
{ name: "MySQL", env: { "DATABASE_ADAPTER" => "mysql2", "FORCE_DB_CONFIG" => "true", "PARALLEL_WORKERS" => "1" }, emoji: "🐬" }
|
113
|
-
]
|
114
|
-
|
115
|
-
results = {}
|
116
|
-
|
117
|
-
databases.each do |db|
|
118
|
-
puts "\n" + "="*60
|
119
|
-
puts "#{db[:emoji]} Testing with #{db[:name]}..."
|
120
|
-
puts "="*60
|
121
|
-
|
122
|
-
begin
|
123
|
-
env = ENV.to_h.merge(db[:env])
|
124
|
-
success = system(env, "rails test:all")
|
125
|
-
|
126
|
-
results[db[:name]] = success ? "✅ PASSED" : "❌ FAILED"
|
127
|
-
rescue => e
|
128
|
-
results[db[:name]] = "❌ FAILED"
|
129
|
-
puts "Error: #{e.message}"
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
# Print summary
|
134
|
-
puts "\n" + "="*60
|
135
|
-
puts "🏁 TEST MATRIX SUMMARY"
|
136
|
-
puts "="*60
|
137
|
-
results.each do |db, status|
|
138
|
-
puts "#{status} #{db}"
|
139
|
-
end
|
140
|
-
puts "="*60
|
141
|
-
|
142
|
-
# Fail if any tests failed
|
143
|
-
failed_count = results.values.count { |status| status.include?("FAILED") }
|
144
|
-
if failed_count > 0
|
145
|
-
puts "\n❌ #{failed_count} database(s) failed tests"
|
146
|
-
exit 1
|
147
|
-
else
|
148
|
-
puts "\n🎉 All databases passed!"
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
desc "Run full test matrix (SQLite + PostgreSQL + MySQL)"
|
153
|
-
task :matrix_full do
|
154
|
-
puts "\n🧪 Running full test matrix...\n"
|
155
|
-
|
156
|
-
databases = [
|
157
|
-
{ name: "SQLite", env: {}, emoji: "🗂️" },
|
158
|
-
{ name: "PostgreSQL", env: { "DATABASE_ADAPTER" => "postgresql", "FORCE_DB_CONFIG" => "true" }, emoji: "🐘" },
|
159
|
-
{ name: "MySQL", env: { "DATABASE_ADAPTER" => "mysql2", "FORCE_DB_CONFIG" => "true", "PARALLEL_WORKERS" => "1" }, emoji: "🐬" }
|
160
|
-
]
|
161
|
-
|
162
|
-
results = {}
|
163
|
-
|
164
|
-
databases.each do |db|
|
165
|
-
puts "\n" + "="*60
|
166
|
-
puts "#{db[:emoji]} Testing with #{db[:name]}..."
|
167
|
-
puts "="*60
|
168
|
-
|
169
|
-
begin
|
170
|
-
env = ENV.to_h.merge(db[:env])
|
171
|
-
success = system(env, "rails test:all")
|
172
|
-
|
173
|
-
results[db[:name]] = success ? "✅ PASSED" : "❌ FAILED"
|
174
|
-
rescue => e
|
175
|
-
results[db[:name]] = "❌ FAILED"
|
176
|
-
puts "Error: #{e.message}"
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
# Print summary
|
181
|
-
puts "\n" + "="*60
|
182
|
-
puts "🏁 FULL TEST MATRIX SUMMARY"
|
183
|
-
puts "="*60
|
184
|
-
results.each do |db, status|
|
185
|
-
puts "#{status} #{db}"
|
186
|
-
end
|
187
|
-
puts "="*60
|
188
|
-
|
189
|
-
# Fail if any tests failed
|
190
|
-
failed_count = results.values.count { |status| status.include?("FAILED") }
|
191
|
-
if failed_count > 0
|
192
|
-
puts "\n❌ #{failed_count} database(s) failed tests"
|
193
|
-
exit 1
|
194
|
-
else
|
195
|
-
puts "\n🎉 All databases passed!"
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
# Helper methods
|
201
|
-
def mysql_available?
|
202
|
-
system("mysql --version > /dev/null 2>&1")
|
203
|
-
end
|
204
|
-
|
205
|
-
def postgresql_available?
|
206
|
-
system("psql --version > /dev/null 2>&1")
|
207
|
-
end
|
@@ -47,8 +47,8 @@ module RailsPulse
|
|
47
47
|
|
48
48
|
# Remove extra whitespace and truncate
|
49
49
|
cleaned_sql = sql.gsub(/\s+/, " ").strip
|
50
|
-
if cleaned_sql.length >
|
51
|
-
"#{cleaned_sql[0..
|
50
|
+
if cleaned_sql.length > 80
|
51
|
+
"#{cleaned_sql[0..79]}..."
|
52
52
|
else
|
53
53
|
cleaned_sql
|
54
54
|
end
|
@@ -3,41 +3,60 @@ module RailsPulse
|
|
3
3
|
module Tables
|
4
4
|
class SlowRoutes
|
5
5
|
include RailsPulse::FormattingHelper
|
6
|
+
|
6
7
|
def to_table_data
|
7
|
-
# Get data for this week
|
8
|
+
# Get data for this week and last week
|
8
9
|
this_week_start = 1.week.ago.beginning_of_week
|
9
10
|
this_week_end = Time.current.end_of_week
|
11
|
+
last_week_start = 2.weeks.ago.beginning_of_week
|
12
|
+
last_week_end = 1.week.ago.beginning_of_week
|
10
13
|
|
11
|
-
#
|
12
|
-
|
14
|
+
# Get this week's data
|
15
|
+
this_week_data = RailsPulse::Request.joins(:route)
|
13
16
|
.where(occurred_at: this_week_start..this_week_end)
|
14
17
|
.group("rails_pulse_routes.path, rails_pulse_routes.id")
|
15
|
-
.select("rails_pulse_routes.path, rails_pulse_routes.id, AVG(rails_pulse_requests.duration) as avg_duration, COUNT(*) as request_count
|
18
|
+
.select("rails_pulse_routes.path, rails_pulse_routes.id, AVG(rails_pulse_requests.duration) as avg_duration, COUNT(*) as request_count")
|
16
19
|
.order("avg_duration DESC")
|
17
20
|
.limit(5)
|
18
21
|
|
19
|
-
#
|
20
|
-
|
22
|
+
# Get last week's data for comparison
|
23
|
+
last_week_averages = RailsPulse::Request.joins(:route)
|
24
|
+
.where(occurred_at: last_week_start..last_week_end)
|
25
|
+
.group("rails_pulse_routes.path")
|
26
|
+
.average("rails_pulse_requests.duration")
|
27
|
+
|
28
|
+
# Build result array matching test expectations
|
29
|
+
this_week_data.map do |record|
|
30
|
+
this_week_avg = record.avg_duration.to_f.round(0)
|
31
|
+
last_week_avg = last_week_averages[record.path]&.round(0) || 0
|
32
|
+
|
33
|
+
# Calculate percentage change
|
34
|
+
percentage_change = if last_week_avg == 0
|
35
|
+
this_week_avg > 0 ? 100.0 : 0.0
|
36
|
+
else
|
37
|
+
((this_week_avg - last_week_avg) / last_week_avg.to_f * 100).round(1)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Determine trend (worse = slower response times)
|
41
|
+
trend = if last_week_avg == 0
|
42
|
+
this_week_avg > 0 ? "worse" : "stable"
|
43
|
+
elsif this_week_avg > last_week_avg
|
44
|
+
"worse" # Slower = worse
|
45
|
+
elsif this_week_avg < last_week_avg
|
46
|
+
"better" # Faster = better
|
47
|
+
else
|
48
|
+
"stable"
|
49
|
+
end
|
50
|
+
|
21
51
|
{
|
22
52
|
route_path: record.path,
|
23
|
-
|
24
|
-
|
25
|
-
|
53
|
+
this_week_avg: this_week_avg,
|
54
|
+
last_week_avg: last_week_avg,
|
55
|
+
percentage_change: percentage_change,
|
26
56
|
request_count: record.request_count,
|
27
|
-
|
57
|
+
trend: trend
|
28
58
|
}
|
29
59
|
end
|
30
|
-
|
31
|
-
# Return new structure with columns and data
|
32
|
-
{
|
33
|
-
columns: [
|
34
|
-
{ field: :route_path, label: "Route", link_to: :route_link, class: "w-auto" },
|
35
|
-
{ field: :average_time, label: "Average Time", class: "w-32" },
|
36
|
-
{ field: :request_count, label: "Requests", class: "w-24" },
|
37
|
-
{ field: :last_request, label: "Last Request", class: "w-32" }
|
38
|
-
],
|
39
|
-
data: data_rows
|
40
|
-
}
|
41
60
|
end
|
42
61
|
end
|
43
62
|
end
|
@@ -133,7 +133,12 @@ module RailsPulse
|
|
133
133
|
|
134
134
|
def validate_authentication_settings!
|
135
135
|
if @authentication_enabled && @authentication_method.nil?
|
136
|
-
Rails.logger
|
136
|
+
# Use Rails.logger if available, otherwise fall back to puts (for asset precompilation)
|
137
|
+
if Rails.logger
|
138
|
+
Rails.logger.warn "RailsPulse: Authentication is enabled but no authentication method is configured. This will deny all access."
|
139
|
+
else
|
140
|
+
puts "RailsPulse: Authentication is enabled but no authentication method is configured. This will deny all access."
|
141
|
+
end
|
137
142
|
end
|
138
143
|
|
139
144
|
if @authentication_method && ![ Proc, Symbol, String, NilClass ].include?(@authentication_method.class)
|
data/lib/rails_pulse/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_pulse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rails Pulse
|
@@ -318,7 +318,7 @@ licenses:
|
|
318
318
|
metadata:
|
319
319
|
allowed_push_host: https://rubygems.org
|
320
320
|
homepage_uri: https://www.railspulse.com
|
321
|
-
source_code_uri: https://github.com/
|
321
|
+
source_code_uri: https://github.com/railspulse/rails_pulse
|
322
322
|
rdoc_options: []
|
323
323
|
require_paths:
|
324
324
|
- lib
|