Class: GoodJob::MetricsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/good_job/metrics_controller.rb

Instance Method Summary collapse

Instance Method Details

#job_statusObject



28
29
30
31
32
# File 'app/controllers/good_job/metrics_controller.rb', line 28

def job_status
  @filter = JobsFilter.new(params)

  render json: @filter.states.transform_values { |count| helpers.number_with_delimiter(count) }
end

#primary_navObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/good_job/metrics_controller.rb', line 5

def primary_nav
  jobs_count = GoodJob::Job.count
  batches_count = GoodJob::BatchRecord.all.size
  cron_entries = GoodJob::CronEntry.all
  cron_entries_count = cron_entries.size
  cron_entries_enabled_count = cron_entries.count(&:enabled?)
  cron_entries_paused_count = cron_entries_count - cron_entries_enabled_count
  pauses_count = GoodJob::Setting.paused.values.sum(&:count)
  processes_count = GoodJob::Process.active.count
  discarded_count = GoodJob::Job.discarded.count

  render json: {
    jobs_count: helpers.number_to_human(jobs_count),
    batches_count: helpers.number_to_human(batches_count),
    cron_entries_count: helpers.number_to_human(cron_entries_count),
    cron_entries_enabled_count: helpers.number_to_human(cron_entries_enabled_count),
    cron_entries_paused_count: helpers.number_to_human(cron_entries_paused_count),
    pauses_count: helpers.number_to_human(pauses_count),
    processes_count: helpers.number_to_human(processes_count),
    discarded_count: helpers.number_to_human(discarded_count),
  }
end