Module: Sidekiqtui

Defined in:
lib/sidekiqtui.rb,
lib/sidekiqtui/version.rb

Constant Summary collapse

VERSION =
'0.1.2'

Class Method Summary collapse

Class Method Details

.configureObject



44
45
46
47
48
# File 'lib/sidekiqtui.rb', line 44

def configure
  Sidekiq.configure_server do |config|
    config.logger = nil
  end
end

.runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sidekiqtui.rb', line 16

def run
  configure

  box = TTY::Box.frame(
    width: TTY::Screen.width,
    height: TTY::Screen.height,
    title: { top_left: 'Scheduled Jobs', bottom_right: Sidekiqtui::VERSION }
  ) do
    ss = Sidekiq::ScheduledSet.new
    jobs = ss.map do |job|
      [
        "in #{time_ago_in_words(job.at)}",
        job.queue,
        job.item['class'],
        job.args.join(', ')
      ]
    end.reverse

    table = TTY::Table.new(
      %w[When Queue Job Arguments],
      jobs
    )
    table.render(:unicode)
  end

  print box
end