Sha256: 6f0898a8661b356ce510917cba0c1be1f1c4454bcfc3474c79f12d397e5e5cd4

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 Bytes

Contents

module Sidekiq
  module Statistic
    class Charts < Base
      def information_for(type)
        worker_names.map do |worker|
          color = color_for(worker)
          {
            label: worker,
            fillColor: "rgba(#{color},0.2)",
            strokeColor: "rgba(#{color},0.9)",
            pointColor: "rgba(#{color},0.2)",
            pointStrokeColor: '#fff',
            pointHighlightFill: '#fff',
            pointHighlightStroke: 'rgba(220,220,220,1)',
            data: statistic_for(worker).map{ |val| val.fetch(type, 0) }
          }
        end
      end

      def color_for(worker)
        Digest::MD5.hexdigest(worker)[0..5]
          .scan(/../)
          .map{ |color| color.to_i(16) }
          .join ','
      end

      def dates
        @dates ||= statistic_hash.flat_map(&:keys)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-statistic-1.1.0 lib/sidekiq/statistic/statistic/charts.rb
sidekiq-statistic-1.0.0 lib/sidekiq/statistic/statistic/charts.rb