Skip to content

Commit 3ef393c

Browse files
authored
Merge pull request #313 from indentlabs/sidekiq
Replace delayed_job with Sidekiq
2 parents 7d210e7 + 3f5ada6 commit 3ef393c

File tree

12 files changed

+48
-28
lines changed

12 files changed

+48
-28
lines changed

Gemfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ ruby "~> 2.5"
44
gem 'rails', '~> 5.2'
55
gem 'puma', '~> 3.7'
66
gem 'puma-heroku'
7-
gem 'rack-timeout'
87

98
# Storage
109
gem 'aws-sdk', '~> 1.5'
@@ -66,7 +65,10 @@ gem 'skylight'
6665
# Forum
6766
gem 'thredded'
6867
gem 'rails-ujs'
69-
gem 'delayed_job_active_record'
68+
69+
# Workers
70+
gem 'sidekiq'
71+
gem 'redis'
7072

7173
# Exports
7274
gem 'csv'

Gemfile.lock

+10-8
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ GEM
120120
execjs
121121
coffee-script-source (1.12.2)
122122
concurrent-ruby (1.1.3)
123+
connection_pool (2.2.2)
123124
crack (0.4.3)
124125
safe_yaml (~> 1.0.0)
125126
crass (1.0.4)
@@ -152,11 +153,6 @@ GEM
152153
db_text_search (0.3.0)
153154
activerecord (>= 4.1.15, < 6.0)
154155
debug_inspector (0.0.3)
155-
delayed_job (4.1.5)
156-
activesupport (>= 3.0, < 5.3)
157-
delayed_job_active_record (4.1.3)
158-
activerecord (>= 3.0, < 5.3)
159-
delayed_job (>= 3.0, < 5)
160156
devise (4.4.3)
161157
bcrypt (~> 3.0)
162158
orm_adapter (~> 0.1)
@@ -319,9 +315,10 @@ GEM
319315
rack-pjax (1.0.0)
320316
nokogiri (~> 1.5)
321317
rack (>= 1.1)
318+
rack-protection (2.0.4)
319+
rack
322320
rack-test (1.1.0)
323321
rack (>= 1.0, < 3)
324-
rack-timeout (0.5.1)
325322
rails (5.2.1.1)
326323
actioncable (= 5.2.1.1)
327324
actionmailer (= 5.2.1.1)
@@ -380,6 +377,7 @@ GEM
380377
rb-inotify (0.9.10)
381378
ffi (>= 0.5.0, < 2)
382379
redcarpet (3.4.0)
380+
redis (4.0.3)
383381
remotipart (1.4.2)
384382
responders (2.4.0)
385383
actionpack (>= 4.2.0, < 5.3)
@@ -453,6 +451,10 @@ GEM
453451
shellany (0.0.1)
454452
shoulda-matchers (3.1.2)
455453
activesupport (>= 4.0.0)
454+
sidekiq (5.2.3)
455+
connection_pool (~> 2.2, >= 2.2.2)
456+
rack-protection (>= 1.5.0)
457+
redis (>= 3.3.5, < 5)
456458
simplecov (0.13.0)
457459
docile (~> 1.1.0)
458460
json (>= 1.8, < 3)
@@ -553,7 +555,6 @@ DEPENDENCIES
553555
cucumber-rails
554556
database_cleaner
555557
dateslices
556-
delayed_job_active_record
557558
devise
558559
factory_bot_rails
559560
filesize
@@ -576,7 +577,6 @@ DEPENDENCIES
576577
puma (~> 3.7)
577578
puma-heroku
578579
rack-mini-profiler
579-
rack-timeout
580580
rails (~> 5.2)
581581
rails-controller-testing
582582
rails-jquery-autocomplete
@@ -585,6 +585,7 @@ DEPENDENCIES
585585
rails_12factor
586586
rails_admin (~> 1.3)
587587
redcarpet
588+
redis
588589
rmagick
589590
rspec-prof
590591
rspec-rails
@@ -594,6 +595,7 @@ DEPENDENCIES
594595
selenium-webdriver
595596
serendipitous!
596597
shoulda-matchers (~> 3.1)
598+
sidekiq
597599
simplecov
598600
skylight
599601
slack-notifier

Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
web: bundle exec puma -C config/puma.rb
2-
worker: bundle exec rake jobs:work
2+
worker: bundle exec sidekiq -e production -C config/sidekiq.yml

app/models/serializers/content_serializer.rb

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def initialize(content)
104104
# ]
105105
# }
106106
def old_style_link_fields
107+
# TODO I think we can remove this method
108+
return {}
109+
107110
categories = Hash[YAML.load_file(Rails.root.join('config', 'attributes', "#{self.class_name.downcase}.yml")).map do |category_name, details|
108111
[
109112
category_name.to_s,

app/views/content/display/_sidelinks.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
next unless category[:fields].any? do |field|
4949
(
5050
# This is a link field AND it has existing links
51-
field[:field_type] == 'link' && field[:old_column_source].present? && raw_model.send(field[:old_column_source]).any?
51+
field[:type] == 'link' && field[:old_column_source].present? && raw_model.send(field[:old_column_source]).any?
5252
) || field[:value].present?
5353
# or: this is a text field with text in it
5454
end

app/views/thredded/users/_link.html.erb

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<% if user %>
22
<% if !user.thredded_anonymous? %>
3-
<a href="<%= user_path(user) %>"><%= user.thredded_display_name %></a>
4-
<%= render partial: 'thredded/users/badge', locals: { user: user } %>
3+
<% user_path = user_path(user) %>
4+
<% if user_path.blank? %>
5+
<span class='thredded--username'><%= user.thredded_display_name %></span>
6+
<% else %>
7+
<a href="<%= user_path %>"><%= user.thredded_display_name %></a>
8+
<%= render partial: 'thredded/users/badge', locals: { user: user } %>
9+
<% end %>
510
<% else %>
611
<%= user.thredded_display_name %>
7-
<%= render partial: 'thredded/users/badge', locals: { user: user } %>
812
<% end %>
913
<% else %>
1014
<em><%= t 'thredded.null_user_name' %></em>

config/application.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Application < Rails::Application
2323
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
2424
# config.i18n.default_locale = :de
2525

26-
# Use delayed_job to process jobs
27-
config.active_job.queue_adapter = :delayed_job
26+
# Use sidekiq to process jobs
27+
config.active_job.queue_adapter = :sidekiq
2828
end
2929
end

config/initializers/paperclip.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
1+
# TODO we can probably remove this. Need to figure out what we're using for uploads again.
2+
3+
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'

config/initializers/rack_timeout.rb

-1
This file was deleted.

config/initializers/thredded.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
# Thredded.notifiers = [Thredded::EmailNotifier.new]
153153
#
154154
# none:
155-
#Thredded.notifiers = []
155+
Thredded.notifiers = []
156156
#
157157
# add in (must install separate gem (under development) as well):
158158
# Thredded.notifiers = [Thredded::EmailNotifier.new, Thredded::PushoverNotifier.new(ENV['PUSHOVER_APP_ID'])]

config/routes.rb

+15-8
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,17 @@
179179
end
180180
get 'search/', to: 'search#results'
181181

182-
scope 'admin' do
183-
get '/stats', to: 'admin#dashboard', as: :admin_dashboard
184-
get '/content_type/:type', to: 'admin#content_type', as: :admin_content_type
185-
get '/attributes', to: 'admin#attributes', as: :admin_attributes
186-
get '/masquerade/:user_id', to: 'admin#masquerade', as: :masquerade
187-
get '/unsubscribe', to: 'admin#unsubscribe', as: :mass_unsubscribe
188-
post '/perform_unsubscribe', to: 'admin#perform_unsubscribe', as: :perform_unsubscribe
182+
authenticate :user, lambda { |u| u.site_administrator? } do
183+
scope 'admin' do
184+
get '/stats', to: 'admin#dashboard', as: :admin_dashboard
185+
get '/content_type/:type', to: 'admin#content_type', as: :admin_content_type
186+
get '/attributes', to: 'admin#attributes', as: :admin_attributes
187+
get '/masquerade/:user_id', to: 'admin#masquerade', as: :masquerade
188+
get '/unsubscribe', to: 'admin#unsubscribe', as: :mass_unsubscribe
189+
post '/perform_unsubscribe', to: 'admin#perform_unsubscribe', as: :perform_unsubscribe
190+
end
191+
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
189192
end
190-
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
191193

192194
scope 'export' do
193195
get '/', to: 'export#index', as: :notebook_export
@@ -267,6 +269,11 @@
267269
# get '/forum/:wildcard/:another', to: 'emergency#temporarily_disabled'
268270
mount Thredded::Engine => '/forum'
269271
mount StripeEvent::Engine, at: '/webhooks/stripe'
272+
273+
require 'sidekiq/web'
274+
authenticate :user, lambda { |u| u.site_administrator? } do
275+
mount Sidekiq::Web => '/sidekiq'
276+
end
270277
end
271278

272279
# rubocop:enable LineLength

config/sidekiq.rb

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:concurrency: 1

0 commit comments

Comments
 (0)