Skip to content

Commit

Permalink
Merge pull request #313 from indentlabs/sidekiq
Browse files Browse the repository at this point in the history
Replace delayed_job with Sidekiq
  • Loading branch information
drusepth authored Dec 4, 2018
2 parents 7d210e7 + 3f5ada6 commit 3ef393c
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 28 deletions.
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ ruby "~> 2.5"
gem 'rails', '~> 5.2'
gem 'puma', '~> 3.7'
gem 'puma-heroku'
gem 'rack-timeout'

# Storage
gem 'aws-sdk', '~> 1.5'
Expand Down Expand Up @@ -66,7 +65,10 @@ gem 'skylight'
# Forum
gem 'thredded'
gem 'rails-ujs'
gem 'delayed_job_active_record'

# Workers
gem 'sidekiq'
gem 'redis'

# Exports
gem 'csv'
Expand Down
18 changes: 10 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.3)
connection_pool (2.2.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.4)
Expand Down Expand Up @@ -152,11 +153,6 @@ GEM
db_text_search (0.3.0)
activerecord (>= 4.1.15, < 6.0)
debug_inspector (0.0.3)
delayed_job (4.1.5)
activesupport (>= 3.0, < 5.3)
delayed_job_active_record (4.1.3)
activerecord (>= 3.0, < 5.3)
delayed_job (>= 3.0, < 5)
devise (4.4.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand Down Expand Up @@ -319,9 +315,10 @@ GEM
rack-pjax (1.0.0)
nokogiri (~> 1.5)
rack (>= 1.1)
rack-protection (2.0.4)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rack-timeout (0.5.1)
rails (5.2.1.1)
actioncable (= 5.2.1.1)
actionmailer (= 5.2.1.1)
Expand Down Expand Up @@ -380,6 +377,7 @@ GEM
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
redcarpet (3.4.0)
redis (4.0.3)
remotipart (1.4.2)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
Expand Down Expand Up @@ -453,6 +451,10 @@ GEM
shellany (0.0.1)
shoulda-matchers (3.1.2)
activesupport (>= 4.0.0)
sidekiq (5.2.3)
connection_pool (~> 2.2, >= 2.2.2)
rack-protection (>= 1.5.0)
redis (>= 3.3.5, < 5)
simplecov (0.13.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
Expand Down Expand Up @@ -553,7 +555,6 @@ DEPENDENCIES
cucumber-rails
database_cleaner
dateslices
delayed_job_active_record
devise
factory_bot_rails
filesize
Expand All @@ -576,7 +577,6 @@ DEPENDENCIES
puma (~> 3.7)
puma-heroku
rack-mini-profiler
rack-timeout
rails (~> 5.2)
rails-controller-testing
rails-jquery-autocomplete
Expand All @@ -585,6 +585,7 @@ DEPENDENCIES
rails_12factor
rails_admin (~> 1.3)
redcarpet
redis
rmagick
rspec-prof
rspec-rails
Expand All @@ -594,6 +595,7 @@ DEPENDENCIES
selenium-webdriver
serendipitous!
shoulda-matchers (~> 3.1)
sidekiq
simplecov
skylight
slack-notifier
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: bundle exec puma -C config/puma.rb
worker: bundle exec rake jobs:work
worker: bundle exec sidekiq -e production -C config/sidekiq.yml
3 changes: 3 additions & 0 deletions app/models/serializers/content_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def initialize(content)
# ]
# }
def old_style_link_fields
# TODO I think we can remove this method
return {}

categories = Hash[YAML.load_file(Rails.root.join('config', 'attributes', "#{self.class_name.downcase}.yml")).map do |category_name, details|
[
category_name.to_s,
Expand Down
2 changes: 1 addition & 1 deletion app/views/content/display/_sidelinks.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
next unless category[:fields].any? do |field|
(
# This is a link field AND it has existing links
field[:field_type] == 'link' && field[:old_column_source].present? && raw_model.send(field[:old_column_source]).any?
field[:type] == 'link' && field[:old_column_source].present? && raw_model.send(field[:old_column_source]).any?
) || field[:value].present?
# or: this is a text field with text in it
end
Expand Down
10 changes: 7 additions & 3 deletions app/views/thredded/users/_link.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<% if user %>
<% if !user.thredded_anonymous? %>
<a href="<%= user_path(user) %>"><%= user.thredded_display_name %></a>
<%= render partial: 'thredded/users/badge', locals: { user: user } %>
<% user_path = user_path(user) %>
<% if user_path.blank? %>
<span class='thredded--username'><%= user.thredded_display_name %></span>
<% else %>
<a href="<%= user_path %>"><%= user.thredded_display_name %></a>
<%= render partial: 'thredded/users/badge', locals: { user: user } %>
<% end %>
<% else %>
<%= user.thredded_display_name %>
<%= render partial: 'thredded/users/badge', locals: { user: user } %>
<% end %>
<% else %>
<em><%= t 'thredded.null_user_name' %></em>
Expand Down
4 changes: 2 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Application < Rails::Application
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Use delayed_job to process jobs
config.active_job.queue_adapter = :delayed_job
# Use sidekiq to process jobs
config.active_job.queue_adapter = :sidekiq
end
end
4 changes: 3 additions & 1 deletion config/initializers/paperclip.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
# TODO we can probably remove this. Need to figure out what we're using for uploads again.

Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
1 change: 0 additions & 1 deletion config/initializers/rack_timeout.rb

This file was deleted.

2 changes: 1 addition & 1 deletion config/initializers/thredded.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
# Thredded.notifiers = [Thredded::EmailNotifier.new]
#
# none:
#Thredded.notifiers = []
Thredded.notifiers = []
#
# add in (must install separate gem (under development) as well):
# Thredded.notifiers = [Thredded::EmailNotifier.new, Thredded::PushoverNotifier.new(ENV['PUSHOVER_APP_ID'])]
23 changes: 15 additions & 8 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,17 @@
end
get 'search/', to: 'search#results'

scope 'admin' do
get '/stats', to: 'admin#dashboard', as: :admin_dashboard
get '/content_type/:type', to: 'admin#content_type', as: :admin_content_type
get '/attributes', to: 'admin#attributes', as: :admin_attributes
get '/masquerade/:user_id', to: 'admin#masquerade', as: :masquerade
get '/unsubscribe', to: 'admin#unsubscribe', as: :mass_unsubscribe
post '/perform_unsubscribe', to: 'admin#perform_unsubscribe', as: :perform_unsubscribe
authenticate :user, lambda { |u| u.site_administrator? } do
scope 'admin' do
get '/stats', to: 'admin#dashboard', as: :admin_dashboard
get '/content_type/:type', to: 'admin#content_type', as: :admin_content_type
get '/attributes', to: 'admin#attributes', as: :admin_attributes
get '/masquerade/:user_id', to: 'admin#masquerade', as: :masquerade
get '/unsubscribe', to: 'admin#unsubscribe', as: :mass_unsubscribe
post '/perform_unsubscribe', to: 'admin#perform_unsubscribe', as: :perform_unsubscribe
end
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
end
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'

scope 'export' do
get '/', to: 'export#index', as: :notebook_export
Expand Down Expand Up @@ -267,6 +269,11 @@
# get '/forum/:wildcard/:another', to: 'emergency#temporarily_disabled'
mount Thredded::Engine => '/forum'
mount StripeEvent::Engine, at: '/webhooks/stripe'

require 'sidekiq/web'
authenticate :user, lambda { |u| u.site_administrator? } do
mount Sidekiq::Web => '/sidekiq'
end
end

# rubocop:enable LineLength
1 change: 1 addition & 0 deletions config/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:concurrency: 1

0 comments on commit 3ef393c

Please sign in to comment.