Sha256: bb9a01a1adf60eb2a96788097f99c7bcd464495b3c3a45c8edde0d87c2934237

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true

require 'json'

module Sidekiq
  module Statistic
    module WebApiExtension
      def self.registered(app)
        app.helpers WebExtensionHelper

        app.before '/api/*' do
          type = :json
        end

        app.get '/api/statistic.json' do
          statistic = Sidekiq::Statistic::Workers.new(*calculate_date_range(params))
          Sidekiq.dump_json(workers: statistic.display)
        end

        app.get '/api/statistic/:worker.json' do
          worker_statistic =
            Sidekiq::Statistic::Workers
              .new(*calculate_date_range(params))
              .display_per_day(params[:worker])

          Sidekiq.dump_json(days: worker_statistic)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekiq-statistic-1.4.0 lib/sidekiq/statistic/web_api_extension.rb