Class: ActiveAdminSidekiqStats::Panel

Inherits:
Object
  • Object
show all
Defined in:
lib/activeadmin_sidekiq_stats/panel.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.injectObject



5
6
7
8
# File 'lib/activeadmin_sidekiq_stats/panel.rb', line 5

def self.inject
  klass = new
  klass.inject!
end

Instance Method Details

#inject!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/activeadmin_sidekiq_stats/panel.rb', line 10

def inject!
    html = Arbre::Context.new do
    panel "Sidekiq Stats" do
      begin
        sidekiq = JSON.parse(::Sidekiq::Stats.new.to_json)
        stats = sidekiq.fetch("stats", Hash.new)
          div style: "display: flex; justify-content: center; align-items: center" do
            stats.each do |process_name, process_value|
              div style: "display: flex; flex:1; justify-content: center; align-items: center; flex-direction: column" do
                h1 process_value
                span process_name.titleize
              end
            end
          end
      rescue Redis::CannotConnectError
        h1 "Redis Connection Failed"
      end
    end
  end
  html.to_s
end