Skip to content

Commit

Permalink
add resque scheduler for discussion update emails
Browse files Browse the repository at this point in the history
  • Loading branch information
arpansac committed Dec 25, 2018
1 parent 6795e8a commit 608bde6
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ gem 'aws-sdk-s3', require: false

gem 'resque'

gem 'resque-scheduler'

gem 'font-awesome-rails'

gem 'momentjs-rails'
Expand Down
14 changes: 14 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ GEM
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
erubi (1.7.1)
et-orbi (1.1.6)
tzinfo
execjs (2.7.0)
faraday (0.12.2)
multipart-post (>= 1.2, < 3)
Expand All @@ -106,6 +108,9 @@ GEM
railties (>= 3.2, < 6.0)
friendly_id (5.1.0)
activerecord (>= 4.0.0)
fugit (1.1.6)
et-orbi (~> 1.1, >= 1.1.6)
raabro (~> 1.1)
globalid (0.4.1)
activesupport (>= 4.2.0)
hashie (3.5.7)
Expand Down Expand Up @@ -176,6 +181,7 @@ GEM
popper_js (1.12.9)
public_suffix (3.0.2)
puma (3.12.0)
raabro (1.1.6)
rack (2.0.5)
rack-cors (1.0.2)
rack-protection (2.0.3)
Expand Down Expand Up @@ -228,13 +234,20 @@ GEM
redis-namespace (~> 1.3)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
resque-scheduler (4.3.1)
mono_logger (~> 1.0)
redis (>= 3.3, < 5)
resque (~> 1.26)
rufus-scheduler (~> 3.2)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
ruby-graphviz (1.2.3)
ruby_dep (1.5.0)
rubyzip (1.2.1)
rufus-scheduler (3.5.2)
fugit (~> 1.1, >= 1.1.5)
sass (3.5.7)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
Expand Down Expand Up @@ -322,6 +335,7 @@ DEPENDENCIES
rails (~> 5.2.0)
rails-erd
resque
resque-scheduler
rest-client
sass-rails (~> 5.0)
selenium-webdriver
Expand Down
8 changes: 8 additions & 0 deletions app/jobs/session_discussion_update.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module SessionDiscussionUpdate
@queue = :discussion_messages_mails

def self.perform
DiscussionMessagesWorker.perform
end

end
9 changes: 9 additions & 0 deletions app/views/speaker_resources/session_discussions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,14 @@
</div>
<% end %>
</div>
<script>
let notification = new Noty({
text: '*This is a Beta Feature! <br>Updates will be delivered on email, every midnight!',
theme: 'relax',
type: 'warning',
timeout: 2500,
layout: 'top'
}).show();
</script>

</section>
4 changes: 4 additions & 0 deletions config/resque_schedule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
session_discussion_update_midnight:
cron: "* * * * * Asia/Kolkata"
class: SessionDiscussionUpdate
queue: discussion_messages_mails
40 changes: 39 additions & 1 deletion lib/tasks/resque.rake
Original file line number Diff line number Diff line change
@@ -1,2 +1,40 @@
require 'resque/tasks'
task 'resque:setup' => :environment
task 'resque:setup' => :environment

require 'resque-scheduler'
require 'resque/scheduler/tasks'


namespace :resque do
task :setup do
require 'resque'

# you probably already have this somewhere
Resque.redis = 'localhost:6379'
end

task :setup_schedule => :setup do
require 'resque-scheduler'

# If you want to be able to dynamically change the schedule,
# uncomment this line. A dynamic schedule can be updated via the
# Resque::Scheduler.set_schedule (and remove_schedule) methods.
# When dynamic is set to true, the scheduler process looks for
# schedule changes and applies them on the fly.
# Note: This feature is only available in >=2.0.0.
# Resque::Scheduler.dynamic = true

# The schedule doesn't need to be stored in a YAML, it just needs to
# be a hash. YAML is usually the easiest.
Resque.schedule = YAML.load_file('config/resque_schedule.yml')

# If your schedule already has +queue+ set for each job, you don't
# need to require your jobs. This can be an advantage since it's
# less code that resque-scheduler needs to know about. But in a small
# project, it's usually easier to just include you job classes here.
# So, something like this:
# require 'jobs'
end

task :scheduler => :setup_schedule
end

0 comments on commit 608bde6

Please sign in to comment.