Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.4'
gem 'rails', '~> 6.0.3', '>= 6.0.3.6'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
Expand Down Expand Up @@ -68,3 +68,7 @@ gem 'webpacker-react', '~> 0.3.2'
gem 'js-routes'
gem 'rollbar'
gem 'newrelic_rpm'
gem 'sidekiq'
gem 'sidekiq-failures'
gem 'sidekiq-throttled'
gem 'sidekiq-unique-jobs', '~> 6.0.13'
161 changes: 91 additions & 70 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.3.4)
actionpack (= 6.0.3.4)
actioncable (6.0.4)
actionpack (= 6.0.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.4)
actionpack (= 6.0.3.4)
activejob (= 6.0.3.4)
activerecord (= 6.0.3.4)
activestorage (= 6.0.3.4)
activesupport (= 6.0.3.4)
actionmailbox (6.0.4)
actionpack (= 6.0.4)
activejob (= 6.0.4)
activerecord (= 6.0.4)
activestorage (= 6.0.4)
activesupport (= 6.0.4)
mail (>= 2.7.1)
actionmailer (6.0.3.4)
actionpack (= 6.0.3.4)
actionview (= 6.0.3.4)
activejob (= 6.0.3.4)
actionmailer (6.0.4)
actionpack (= 6.0.4)
actionview (= 6.0.4)
activejob (= 6.0.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3.4)
actionview (= 6.0.3.4)
activesupport (= 6.0.3.4)
actionpack (6.0.4)
actionview (= 6.0.4)
activesupport (= 6.0.4)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.4)
actionpack (= 6.0.3.4)
activerecord (= 6.0.3.4)
activestorage (= 6.0.3.4)
activesupport (= 6.0.3.4)
actiontext (6.0.4)
actionpack (= 6.0.4)
activerecord (= 6.0.4)
activestorage (= 6.0.4)
activesupport (= 6.0.4)
nokogiri (>= 1.8.5)
actionview (6.0.3.4)
activesupport (= 6.0.3.4)
actionview (6.0.4)
activesupport (= 6.0.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand All @@ -51,20 +51,20 @@ GEM
activemodel (>= 4.1, < 6.2)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (6.0.3.4)
activesupport (= 6.0.3.4)
activejob (6.0.4)
activesupport (= 6.0.4)
globalid (>= 0.3.6)
activemodel (6.0.3.4)
activesupport (= 6.0.3.4)
activerecord (6.0.3.4)
activemodel (= 6.0.3.4)
activesupport (= 6.0.3.4)
activestorage (6.0.3.4)
actionpack (= 6.0.3.4)
activejob (= 6.0.3.4)
activerecord (= 6.0.3.4)
marcel (~> 0.3.1)
activesupport (6.0.3.4)
activemodel (6.0.4)
activesupport (= 6.0.4)
activerecord (6.0.4)
activemodel (= 6.0.4)
activesupport (= 6.0.4)
activestorage (6.0.4)
actionpack (= 6.0.4)
activejob (= 6.0.4)
activerecord (= 6.0.4)
marcel (~> 1.0.0)
activesupport (6.0.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand Down Expand Up @@ -93,10 +93,11 @@ GEM
case_transform (0.2)
activesupport
childprocess (3.0.0)
concurrent-ruby (1.1.7)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
crass (1.0.6)
docile (1.4.0)
erubi (1.9.0)
erubi (1.10.0)
factory_bot (6.1.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.1.0)
Expand All @@ -105,7 +106,7 @@ GEM
ffi (1.13.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.5)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
jbuilder (2.10.1)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -135,66 +136,68 @@ GEM
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.7.0)
loofah (2.10.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
marcel (1.0.1)
method_source (1.0.0)
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.2)
mini_mime (1.1.0)
mini_portile2 (2.5.3)
minitest (5.14.4)
msgpack (1.3.3)
newrelic_rpm (7.1.0)
nio4r (2.5.4)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
nio4r (2.5.7)
nokogiri (1.11.7)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
parallel (1.20.1)
parser (3.0.1.0)
ast (~> 2.4.1)
pg (1.2.3)
public_suffix (4.0.6)
puma (4.3.6)
nio4r (~> 2.0)
racc (1.5.2)
rack (2.2.3)
rack-proxy (0.6.5)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3.4)
actioncable (= 6.0.3.4)
actionmailbox (= 6.0.3.4)
actionmailer (= 6.0.3.4)
actionpack (= 6.0.3.4)
actiontext (= 6.0.3.4)
actionview (= 6.0.3.4)
activejob (= 6.0.3.4)
activemodel (= 6.0.3.4)
activerecord (= 6.0.3.4)
activestorage (= 6.0.3.4)
activesupport (= 6.0.3.4)
rails (6.0.4)
actioncable (= 6.0.4)
actionmailbox (= 6.0.4)
actionmailer (= 6.0.4)
actionpack (= 6.0.4)
actiontext (= 6.0.4)
actionview (= 6.0.4)
activejob (= 6.0.4)
activemodel (= 6.0.4)
activerecord (= 6.0.4)
activestorage (= 6.0.4)
activesupport (= 6.0.4)
bundler (>= 1.3.0)
railties (= 6.0.3.4)
railties (= 6.0.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.3.4)
actionpack (= 6.0.3.4)
activesupport (= 6.0.3.4)
railties (6.0.4)
actionpack (= 6.0.4)
activesupport (= 6.0.4)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
rake (13.0.1)
rake (13.0.3)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.3.1)
redis-prescription (1.0.0)
regexp_parser (1.8.2)
responders (3.0.1)
actionpack (>= 5.0)
Expand Down Expand Up @@ -227,6 +230,20 @@ GEM
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
sidekiq (6.2.1)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
sidekiq-failures (1.0.0)
sidekiq (>= 4.0.0)
sidekiq-throttled (0.13.0)
concurrent-ruby
redis-prescription
sidekiq
sidekiq-unique-jobs (6.0.25)
concurrent-ruby (~> 1.0, >= 1.0.5)
sidekiq (>= 4.0, < 7.0)
thor (>= 0.20, < 2.0)
simple_form (5.1.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
Expand Down Expand Up @@ -258,10 +275,10 @@ GEM
activerecord (>= 5.1)
state_machines-activemodel (>= 0.8.0)
temple (0.8.2)
thor (1.0.1)
thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.10)
tzinfo (1.2.7)
tzinfo (1.2.9)
thread_safe (~> 0.1)
unicode-display_width (2.0.0)
uniform_notifier (1.14.2)
Expand All @@ -280,12 +297,12 @@ GEM
railties (>= 4.2)
webpacker-react (0.3.2)
webpacker
websocket-driver (0.7.3)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.4.0)
zeitwerk (2.4.2)

PLATFORMS
ruby
Expand All @@ -307,13 +324,17 @@ DEPENDENCIES
newrelic_rpm
pg (>= 0.18, < 2.0)
puma (~> 4.1)
rails (~> 6.0.3, >= 6.0.3.4)
rails (~> 6.0.3, >= 6.0.3.6)
ransack!
responders
rollbar
rubocop
sass-rails (>= 6)
selenium-webdriver
sidekiq
sidekiq-failures
sidekiq-throttled
sidekiq-unique-jobs (~> 6.0.13)
simple_form
simplecov
slim-rails
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create
task = current_user.my_tasks.new(p)

if task.save
UserMailer.with({ user: current_user, task: task }).task_created.deliver_now
SendTaskCreateNotificationJob.perform_async(task.id)
end

respond_with(task, serializer: TaskSerializer, location: nil)
Expand All @@ -31,7 +31,7 @@ def update
task = Task.find(params[:id])

if task.update(task_params)
UserMailer.with({ task: task }).task_updated.deliver_now
SendTaskUpdateNotificationJob.perform_async(task.id)
end

respond_with(task, serializer: TaskSerializer)
Expand All @@ -41,7 +41,7 @@ def destroy
task = Task.find(params[:id])

if task.destroy
UserMailer.with({ task: task }).task_updated.deliver_now
SendTaskDestroyNotificationJob.perform_async(task.id, task.author_id)
end

respond_with(task)
Expand Down
9 changes: 3 additions & 6 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
class ApplicationJob
include Sidekiq::Worker
include Sidekiq::Throttled::Worker
end
11 changes: 11 additions & 0 deletions app/jobs/send_forgot_password_notification_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class SendForgotPasswordNotificationJob < ApplicationJob
sidekiq_options queue: :mailers
sidekiq_throttle_as :mailer

def perform(user_id)
user = User.find_by(id: user_id)
return if user.blank?

UserMailer.with(user: user).forgot_password.deliver_now
end
end
11 changes: 11 additions & 0 deletions app/jobs/send_task_create_notification_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class SendTaskCreateNotificationJob < ApplicationJob
sidekiq_options queue: :mailers
sidekiq_throttle_as :mailer

def perform(task_id)
task = Task.find_by(id: task_id)
return if task.blank?

UserMailer.with(user: task.author, task: task).task_created.deliver_now
end
end
11 changes: 11 additions & 0 deletions app/jobs/send_task_destroy_notification_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class SendTaskDestroyNotificationJob < ApplicationJob
sidekiq_options queue: :mailers
sidekiq_throttle_as :mailer

def perform(task_id, user_id)
user = User.find_by(id: user_id)
return if user.blank?

UserMailer.with({ user: user, task_id: task_id }).task_deleted.deliver_now
end
end
12 changes: 12 additions & 0 deletions app/jobs/send_task_update_notification_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class SendTaskUpdateNotificationJob < ApplicationJob
sidekiq_options queue: :mailers
sidekiq_throttle_as :mailer
sidekiq_options lock: :until_and_while_executing, on_conflict: { client: :log, server: :reject }

def perform(task_id)
task = Task.find_by(id: task_id)
return if task.blank?

UserMailer.with({ task: task }).task_updated.deliver_now
end
end
5 changes: 3 additions & 2 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ def task_updated
end

def task_deleted
@task = params[:task]
user = params[:user]
@task_id = params[:task_id]

mail(from: 'noreply@taskmanager.com', to: @task.author.email, subject: 'Task Deleted')
mail(from: 'noreply@taskmanager.com', to: user.email, subject: 'Task Deleted')
end

def forgot_password
Expand Down
Loading