Merge pull request #29 from exstake/use-jobs-to-devise-emails

use jobs to devise emails delivery
This commit is contained in:
João Geonizeli
2021-08-18 00:24:12 -03:00
committed by GitHub
8 changed files with 37 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
rails: bundle exec rails server
sidekiq: bundle exec sidekiq
webpack: yarn dev
relay: yarn relay:watch
relay: yarn relay:watch

View File

@@ -19,6 +19,7 @@ gem "devise"
gem "devise-i18n"
gem "paper_trail"
gem "slack-notifier"
gem "sidekiq", "~> 6.2"
gem "administrate-field-active_storage"
gem "administrate-field-enumerize"
gem "tailwindcss-rails"

View File

@@ -90,6 +90,7 @@ GEM
choice (0.2.0)
coderay (1.1.3)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
crass (1.0.6)
datetime_picker_rails (0.0.7)
momentjs-rails (>= 2.8.1)
@@ -237,6 +238,7 @@ GEM
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.4.0)
regexp_parser (2.1.1)
request_store (1.5.0)
rack (>= 1.4)
@@ -302,6 +304,10 @@ GEM
semantic_range (3.0.0)
shoulda-matchers (5.0.0)
activesupport (>= 5.2.0)
sidekiq (6.2.1)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
slack-notifier (2.4.0)
spring (2.1.1)
sprockets (4.0.2)
@@ -374,6 +380,7 @@ DEPENDENCIES
rubocop-shopify
sass-rails (>= 6)
shoulda-matchers (~> 5.0)
sidekiq (~> 6.2)
slack-notifier
spring
tailwindcss-rails

View File

@@ -21,4 +21,10 @@
class AdminUser < ApplicationRecord
devise :database_authenticatable, :recoverable,
:rememberable, :validatable
private
def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver_later
end
end

View File

@@ -51,4 +51,8 @@ class User < ApplicationRecord
def notification_message
"🎉 New user: #{email} 🎉"
end
def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver_later
end
end

View File

@@ -27,15 +27,9 @@ module XStake
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults(6.1)
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
# Don't generate system test files.
config.generators.system_tests = nil
config.active_job.queue_adapter = :sidekiq
end
end

View File

@@ -1,4 +1,6 @@
# frozen_string_literal: true
require "sidekiq/web"
Rails.application.routes.draw do
devise_for :users
devise_for :admin_users
@@ -16,9 +18,15 @@ Rails.application.routes.draw do
root to: "home#index"
get "*all" => "home#index", constraints: lambda { |req|
req.path.exclude?("playground") && req.path.exclude?("rails")
["playground", "rails", "sidekiq"].filter do |path|
req.path != path
end.blank?
}
post "/graphql", to: "graphql#execute"
mount GraphqlPlayground::Rails::Engine, at: "/playground", graphql_path: "/graphql" if Rails.env.development?
if Rails.env.development?
mount GraphqlPlayground::Rails::Engine, at: "/playground", graphql_path: "/graphql"
mount Sidekiq::Web => "/sidekiq"
end
end

View File

@@ -5,9 +5,11 @@ services:
- "3000:3000"
environment:
- DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
- REDIS_URL=redis://redis
image: xstake
depends_on:
- db
- redis
volumes:
- ./:/usr/src/app/
db:
@@ -19,5 +21,8 @@ services:
- "5432:5432"
volumes:
- "data:/var/lib/postgresql/data"
db:
image: redis:6.2-alpine
volumes:
data: