Sha256: 0df9a1cc1e2c937f963cec54cf7c02e4f8b5dc0cd876eb34f03ac56d7a234fd9

Contents?: true

Size: 1.06 KB

Versions: 15

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module GoodJob
  class MetricsController < ApplicationController
    def primary_nav
      jobs_count = GoodJob::Job.count
      batches_count = GoodJob::BatchRecord.migrated? ? GoodJob::BatchRecord.all.size : 0
      cron_entries_count = GoodJob::CronEntry.all.size
      processes_count = GoodJob::Process.active.count

      render json: {
        jobs_count: number_to_human(jobs_count),
        batches_count: number_to_human(batches_count),
        cron_entries_count: number_to_human(cron_entries_count),
        processes_count: number_to_human(processes_count),
      }
    end

    def job_status
      @filter = JobsFilter.new(params)

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

    private

    def number_to_human(count)
      helpers.number_to_human(count, **helpers.translate_hash("good_job.number.human.decimal_units"))
    end

    def number_with_delimiter(count)
      helpers.number_with_delimiter(count, **helpers.translate_hash('good_job.number.format'))
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
good_job-3.99.1 app/controllers/good_job/metrics_controller.rb
good_job-3.99.0 app/controllers/good_job/metrics_controller.rb
good_job-3.30.1 app/controllers/good_job/metrics_controller.rb
good_job-3.30.0 app/controllers/good_job/metrics_controller.rb
good_job-3.29.5 app/controllers/good_job/metrics_controller.rb
good_job-3.29.4 app/controllers/good_job/metrics_controller.rb
good_job-3.29.3 app/controllers/good_job/metrics_controller.rb
good_job-3.28.2 app/controllers/good_job/metrics_controller.rb
good_job-3.28.1 app/controllers/good_job/metrics_controller.rb
good_job-3.28.0 app/controllers/good_job/metrics_controller.rb
good_job-3.27.4 app/controllers/good_job/metrics_controller.rb
good_job-3.27.3 app/controllers/good_job/metrics_controller.rb
good_job-3.27.2 app/controllers/good_job/metrics_controller.rb
good_job-3.27.1 app/controllers/good_job/metrics_controller.rb
good_job-3.27.0 app/controllers/good_job/metrics_controller.rb