Skip to content

Commit

Permalink
Fix presentation of the Queue in the Recurring Jobs page
Browse files Browse the repository at this point in the history
Fixes mattyr#38
  • Loading branch information
Fryguy committed Aug 5, 2022
1 parent 4783b83 commit a87cf69
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
12 changes: 11 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ task :web do
}
end

# throw a fake job in
# throw some fake jobs in
Sidecloq.configure do |config|
sched = Sidecloq::Schedule.from_hash({
my_scheduled_job: {
class: 'DoWork',
cron: '* * * * *',
queue: 'default'
},
my_scheduled_job2: {
class: 'DoWorkWithQueue',
cron: '* * * * *'
}

})
sched.save_redis
config[:schedule] = sched
Expand All @@ -39,6 +44,11 @@ task :web do
include Sidekiq::Worker
end

class DoWorkWithQueue
include Sidekiq::Worker
sidekiq_options queue: "not_default"
end

require 'sidekiq/web'
require 'sidecloq/web'
require 'securerandom'
Expand Down
6 changes: 5 additions & 1 deletion lib/sidecloq/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ module Web

def self.registered(app)
app.get '/recurring' do
@schedule = Schedule.from_redis
@job_specs = Schedule.from_redis.job_specs
@job_specs.each_value do |job_spec|
job_spec['cron'] ||= job_spec['every']
job_spec['queue'] ||= Object.const_get(job_spec['class']).sidekiq_options_hash['queue']
end

erb File.read(File.join(VIEW_PATH, 'recurring.erb'))
end
Expand Down
5 changes: 5 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class DummyJob
include Sidekiq::Worker
end

class DummyJobWithQueue
include Sidekiq::Worker
sidekiq_options :queue => "dummy"
end

require 'active_job'

ActiveJob::Base.queue_adapter = :sidekiq
Expand Down
6 changes: 3 additions & 3 deletions web/views/recurring.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
</thead>

<tbody>
<% @schedule.job_specs.each do |name, job_spec| %>
<% @job_specs.each do |name, job_spec| %>
<tr>
<td><%= name %></td>
<td><%= job_spec.fetch 'cron', job_spec['every'] %></td>
<td><%= job_spec['cron'] %></td>
<td><%= job_spec['class'] %></td>
<td>
<a href="<%= root_path %>queues/<%= job_spec.fetch('queue', 'default') %>"><%= job_spec.fetch('queue', 'default') %></a>
<a href="<%= root_path %>queues/<%= job_spec['queue'] %>"><%= job_spec['queue'] %></a>
</td>
<td><%= job_spec['args'] %></td>
<td>
Expand Down

0 comments on commit a87cf69

Please sign in to comment.