Skip to content

Commit

Permalink
enabling scheduller back
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinicius Gomes committed Jan 4, 2012
1 parent af6ec22 commit 0814ab4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gem 'nokogiri'
gem 'mechanize'
gem 'mongoid', '2.0'
gem 'bson_ext', '~>1.3'
#gem 'ruby-debug'

group :test do
gem 'rspec'
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end
desc 'This task is called by the Heroku Scheduler add-on'
task :subscribe, :email do |t, args|
if !args[:email]
puts '>>> RUNING SUBSCRIBE! <o> \o/ <o> \o/ <o> \o/'#Job.new.run
Job.new.run
else
Mongoid.configure do |config|
production_db = 'mongodb://heroku:[email protected]:27103/app525158'
Expand Down
17 changes: 15 additions & 2 deletions app/models/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,21 @@ def subscribe clubber
log ">>> Subscribing #{clubber.email}..."
Nightclub.all.each do |club|
club.parties.each do |party|
response = party.add_to_list clubber
save_report(club, party, clubber, response)
begin
response = party.add_to_list clubber
save_report(club, party, clubber, response)
rescue
begin
log ">>> Error adding #{clubber.email} to #{club.name} - #{party.name}."
log ">>> Trying again..."
response = party.add_to_list clubber
save_report(club, party, clubber, response)
rescue => e
#require 'ruby-debug';debugger
log ">>> Unable to add #{clubber.email} to #{club.name} - #{party.name}."
log ">>> Reason: #{e}"
end
end
end
end
log ">>> Done."
Expand Down

0 comments on commit 0814ab4

Please sign in to comment.