Class: Newshound::QueReporter
- Inherits:
-
Object
- Object
- Newshound::QueReporter
- Defined in:
- lib/newshound/que_reporter.rb
Instance Attribute Summary collapse
-
#job_source ⇒ Object
readonly
Returns the value of attribute job_source.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#banner_data ⇒ Object
Returns data formatted for the banner UI.
- #generate_report ⇒ Object (also: #report)
-
#initialize(job_source: nil, logger: nil) ⇒ QueReporter
constructor
A new instance of QueReporter.
Constructor Details
#initialize(job_source: nil, logger: nil) ⇒ QueReporter
Returns a new instance of QueReporter.
7 8 9 10 |
# File 'lib/newshound/que_reporter.rb', line 7 def initialize(job_source: nil, logger: nil) @job_source = job_source || (defined?(::Que::Job) ? ::Que::Job : nil) @logger = logger || (defined?(Rails) ? Rails.logger : Logger.new($stdout)) end |
Instance Attribute Details
#job_source ⇒ Object (readonly)
Returns the value of attribute job_source.
5 6 7 |
# File 'lib/newshound/que_reporter.rb', line 5 def job_source @job_source end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/newshound/que_reporter.rb', line 5 def logger @logger end |
Instance Method Details
#banner_data ⇒ Object
Returns data formatted for the banner UI
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/newshound/que_reporter.rb', line 28 def stats = queue_statistics { queue_stats: { ready_to_run: stats[:ready], scheduled: stats[:scheduled], failed: stats[:failed], completed_today: stats[:finished_today] } } end |
#generate_report ⇒ Object Also known as: report
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/newshound/que_reporter.rb', line 12 def generate_report [ { type: "section", text: { type: "mrkdwn", text: "*📊 Que Jobs Status*" } }, job_counts_section, queue_health_section ].compact end |