Class: Newshound::JobReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/newshound/job_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_source: nil, configuration: nil, logger: nil) ⇒ JobReporter

Returns a new instance of JobReporter.



7
8
9
10
11
# File 'lib/newshound/job_reporter.rb', line 7

def initialize(job_source: nil, configuration: nil, logger: nil)
  @configuration = configuration || Newshound.configuration
  @job_source = resolve_job_source(job_source)
  @logger = logger || (defined?(Rails) ? Rails.logger : Logger.new($stdout))
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



5
6
7
# File 'lib/newshound/job_reporter.rb', line 5

def configuration
  @configuration
end

#job_sourceObject (readonly)

Returns the value of attribute job_source.



5
6
7
# File 'lib/newshound/job_reporter.rb', line 5

def job_source
  @job_source
end

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/newshound/job_reporter.rb', line 5

def logger
  @logger
end

Instance Method Details



30
31
32
33
34
# File 'lib/newshound/job_reporter.rb', line 30

def banner_data
  return {queue_stats: {}} unless job_source

  job_source.format_for_banner
end

#generate_reportObject Also known as: report



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/newshound/job_reporter.rb', line 13

def generate_report
  return no_jobs_block unless job_source

  [
    {
      type: "section",
      text: {
        type: "mrkdwn",
        text: "*📊 Job Queue Status*"
      }
    },
    job_counts_section,
    queue_health_section
  ].compact
end