Sha256: 4ab887d7375b7bdb17b0f04399cfb0351ac99af4f17454773d17a5f4bc1ae39c

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module GoodJob
  class MetricsController < ApplicationController
    def primary_nav
      jobs_count = GoodJob::Job.count
      batches_count = GoodJob::BatchRecord.all.size
      cron_entries_count = GoodJob::CronEntry.all.size
      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),
        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

    def job_status
      @filter = JobsFilter.new(params)

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
good_job-4.8.2 app/controllers/good_job/metrics_controller.rb
good_job-4.8.1 app/controllers/good_job/metrics_controller.rb
good_job-4.8.0 app/controllers/good_job/metrics_controller.rb