Sha256: d138bacc43ad18a44696632f3cb0146c6210f3b3e8088c8e9c7cd25f40a8d939

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

require 'json'

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

        app.before '/api/*' do
          content_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

3 entries across 3 versions & 1 rubygems

Version Path
sidekiq-statistic-1.2.0 lib/sidekiq/statistic/web_api_extension.rb
sidekiq-statistic-1.1.0 lib/sidekiq/statistic/web_api_extension.rb
sidekiq-statistic-1.0.0 lib/sidekiq/statistic/web_api_extension.rb