Commit 41560d16 by thanhnd

background jobs with resque

parent 882536bd
Pipeline #641 failed with stages
in 0 seconds
......@@ -75,3 +75,5 @@ gem 'rsolr'
gem 'carrierwave', '~> 2.0'
#using rescue
gem 'resque'
......@@ -148,8 +148,12 @@ GEM
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.0)
mono_logger (1.1.0)
msgpack (1.3.3)
multi_json (1.14.1)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
nio4r (2.5.2)
nokogiri (1.10.8)
......@@ -165,6 +169,8 @@ GEM
puma (4.3.1)
nio4r (~> 2.0)
rack (2.2.2)
rack-protection (2.0.8.1)
rack
rack-proxy (0.6.5)
rack
rack-test (1.1.0)
......@@ -199,15 +205,25 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.1.4)
redis-namespace (1.7.0)
redis (>= 3.0.4)
regexp_parser (1.7.0)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
resque (2.0.0)
mono_logger (~> 1.0)
multi_json (~> 1.0)
redis-namespace (~> 1.6)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
rsolr (2.3.0)
builder (>= 2.1.2)
faraday (>= 0.9.0)
ruby-vips (2.0.17)
ffi (~> 1.9)
ruby2_keywords (0.0.2)
ruby_dep (1.5.0)
rubyzip (2.2.0)
sass-rails (6.0.0)
......@@ -224,6 +240,11 @@ GEM
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
settingslogic (2.0.9)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.8.1)
tilt (~> 2.0)
spring (2.1.0)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
......@@ -244,6 +265,8 @@ GEM
turbolinks-source (5.2.0)
tzinfo (1.2.6)
thread_safe (~> 0.1)
vegas (0.1.11)
rack (>= 1.0.0)
warden (1.2.8)
rack (>= 2.0.6)
web-console (4.0.1)
......@@ -287,6 +310,7 @@ DEPENDENCIES
pry-nav
puma (~> 4.1)
rails (~> 6.0.2, >= 6.0.2.1)
resque
rsolr
sass-rails (>= 6)
selenium-webdriver
......
......@@ -33,7 +33,7 @@ class JobsController < ApplicationController
apply_job.save!
#send email for user applied
JobMailer.with(name: session[:apply_job]["fullname"], email: session[:apply_job]["email"], job_id: session[:job_id], cv_url: session[:apply_job]["cv_url"]).welcome_email.deliver_now
Resque.enqueue(SendMail, apply_job.id)
end
......
......@@ -2,10 +2,10 @@ class JobMailer < ApplicationMailer
default from: 'notifications@example.com'
def welcome_email
@email = params[:email]
@job = Job.find(params[:job_id])
@name = params[:name]
@cv_url = params[:cv_url]
@email = params[:apply_job].email
@job = Job.find(params[:apply_job].job_id)
@name = params[:apply_job].fullname
@cv_url = params[:apply_job].cv_url
mail(to: @email, subject: 'Welcome to My Awesome Site')
end
end
class SendMail
@queue = :applied_queue
class << self
def perform(apply_job_id)
apply_job = AppliedJob.find apply_job_id
JobMailer.with(apply_job: apply_job).welcome_email.deliver_now
#INTERVAL=10 QUEUE=* rake resque:work
end
end
end
Rails.application.routes.draw do
require 'resque/server'
resources :cities, only: [:index]
resources :industries, only: [:index]
resources :jobs, only: [:index]
......@@ -19,6 +20,7 @@ Rails.application.routes.draw do
get 'applyjoblist', to: 'jobs#applyjoblist'
get 'jobs/search' => 'jobs#search', as: :job_search
root 'top_page#index'
mount Resque::Server.new, :at => "/resque"
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :top_page
end
require 'resque/tasks'
task "resque:setup" => :environment
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment