newshound 1.0.2 → 1.0.3
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f63cb577cdf9cc38edce00142a140f07263b9a59ddad4308fa4956b796617e60
|
|
4
|
+
data.tar.gz: ba96c4b481cc3de1b462bba4b53a482e0ece9ac05ebaebc56f65e601b638a2d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb61b7b3f7bb65a5f0f888738ad78087cdc248e0dc512e82f467d4f85314428359443e6e3e5219e3d19c59e7cb63d9594b00e9d35505b4cda7e5e90ec25c9ad5
|
|
7
|
+
data.tar.gz: d86c02b4f21c5f2fc1780846848163a5d1205256c797f5c4138f1eed1ab1fb3c6003b10bdd60735232b375bb5cbf08196c1585bdd6f0d27edfa969896b07e6d4
|
data/CHANGELOG.md
CHANGED
|
@@ -5,21 +5,20 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [1.0.
|
|
8
|
+
## [1.0.3] - 2026-04-21
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
- exception_source_config option for passing connection details to adapters (6d3e2a1)
|
|
14
|
-
- Minimize button for banner (c686227)
|
|
15
|
-
|
|
16
|
-
## [1.0.1] - 2026-03-17
|
|
12
|
+
- failed_jobs_threshold configuration option (0caac13)
|
|
17
13
|
|
|
18
14
|
### Changed
|
|
19
15
|
|
|
20
|
-
-
|
|
16
|
+
- Skip banner injection when there is nothing notable to display (0caac13)
|
|
17
|
+
|
|
18
|
+
## [1.0.2] - 2026-04-03
|
|
21
19
|
|
|
22
20
|
### Added
|
|
23
21
|
|
|
24
|
-
-
|
|
25
|
-
-
|
|
22
|
+
- Bugsink exception source adapter for HTTP-based error tracking (6d3e2a1)
|
|
23
|
+
- exception_source_config option for passing connection details to adapters (6d3e2a1)
|
|
24
|
+
- Minimize button for banner (c686227)
|
|
@@ -19,6 +19,11 @@ Newshound.configure do |config|
|
|
|
19
19
|
# config.job_source = :que # or a custom adapter instance
|
|
20
20
|
# See Newshound::Jobs::Base for the adapter interface
|
|
21
21
|
|
|
22
|
+
# Number of failed jobs at or below which the banner is suppressed
|
|
23
|
+
# Set higher if your app tolerates occasional background job failures
|
|
24
|
+
# Default is 0 (any failed job triggers the banner)
|
|
25
|
+
# config.failed_jobs_threshold = 0
|
|
26
|
+
|
|
22
27
|
# User roles that are authorized to view the Newshound banner
|
|
23
28
|
# These should match the role values in your User model
|
|
24
29
|
# Default is [:developer, :super_user]
|
|
@@ -6,6 +6,7 @@ module Newshound
|
|
|
6
6
|
:current_user_method, :authorization_block, :exception_source,
|
|
7
7
|
:exception_source_config,
|
|
8
8
|
:warning_source, :warning_limit, :job_source,
|
|
9
|
+
:failed_jobs_threshold,
|
|
9
10
|
:exception_links, :job_links, :warning_links
|
|
10
11
|
|
|
11
12
|
def initialize
|
|
@@ -19,6 +20,7 @@ module Newshound
|
|
|
19
20
|
@warning_source = nil
|
|
20
21
|
@warning_limit = 10
|
|
21
22
|
@job_source = nil
|
|
23
|
+
@failed_jobs_threshold = 0
|
|
22
24
|
@exception_links = {}
|
|
23
25
|
@job_links = {}
|
|
24
26
|
@warning_links = {}
|
|
@@ -19,8 +19,9 @@ module Newshound
|
|
|
19
19
|
return [status, headers, response] unless controller
|
|
20
20
|
return [status, headers, response] unless Newshound::Authorization.authorized?(controller)
|
|
21
21
|
|
|
22
|
-
# Get banner HTML
|
|
22
|
+
# Get banner HTML (nil when nothing notable to display)
|
|
23
23
|
banner_html = generate_banner_html
|
|
24
|
+
return [status, headers, response] unless banner_html
|
|
24
25
|
|
|
25
26
|
# Inject banner after <body> tag
|
|
26
27
|
new_response = inject_banner(response, banner_html)
|
|
@@ -62,10 +63,20 @@ module Newshound
|
|
|
62
63
|
job_data = job_reporter.banner_data
|
|
63
64
|
warning_data = warning_reporter.banner_data
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
return nil unless notable_data?(exception_data, job_data, warning_data)
|
|
67
|
+
|
|
66
68
|
render_banner(exception_data, job_data, warning_data)
|
|
67
69
|
end
|
|
68
70
|
|
|
71
|
+
def notable_data?(exception_data, job_data, warning_data)
|
|
72
|
+
exception_count = exception_data[:exceptions]&.length || 0
|
|
73
|
+
failed_jobs = job_data.dig(:queue_stats, :failed) || 0
|
|
74
|
+
warning_count = warning_data[:warnings]&.length || 0
|
|
75
|
+
threshold = Newshound.configuration.failed_jobs_threshold
|
|
76
|
+
|
|
77
|
+
exception_count > 0 || warning_count > 0 || failed_jobs > threshold
|
|
78
|
+
end
|
|
79
|
+
|
|
69
80
|
def render_banner(exception_data, job_data, warning_data = {})
|
|
70
81
|
<<~HTML
|
|
71
82
|
<div id="newshound-banner" class="newshound-banner newshound-collapsed">
|
|
@@ -351,19 +362,17 @@ module Newshound
|
|
|
351
362
|
exception_count = exception_data[:exceptions]&.length || 0
|
|
352
363
|
failed_jobs = job_data.dig(:queue_stats, :failed) || 0
|
|
353
364
|
warning_count = warning_data[:warnings]&.length || 0
|
|
365
|
+
threshold = Newshound.configuration.failed_jobs_threshold
|
|
354
366
|
|
|
355
|
-
if exception_count > 0
|
|
367
|
+
if exception_count > 0
|
|
356
368
|
badge_class = "newshound-error"
|
|
357
|
-
text = "#{exception_count} exceptions
|
|
358
|
-
|
|
369
|
+
text = "#{exception_count} exceptions"
|
|
370
|
+
else
|
|
359
371
|
badge_class = "newshound-warning"
|
|
360
372
|
parts = []
|
|
361
373
|
parts << "#{warning_count} warnings" if warning_count > 0
|
|
362
|
-
parts << "#{failed_jobs} failed jobs" if failed_jobs >
|
|
374
|
+
parts << "#{failed_jobs} failed jobs" if failed_jobs > threshold
|
|
363
375
|
text = parts.join(", ")
|
|
364
|
-
else
|
|
365
|
-
badge_class = "newshound-success"
|
|
366
|
-
text = "All clear"
|
|
367
376
|
end
|
|
368
377
|
|
|
369
378
|
%(<span class="newshound-badge #{badge_class}">#{text}</span>)
|
data/lib/newshound/version.rb
CHANGED