diff options
author | Robin Houston <robin@lenny.robin> | 2011-06-21 03:39:29 +0100 |
---|---|---|
committer | Robin Houston <robin@lenny.robin> | 2011-06-21 03:39:29 +0100 |
commit | d1d4c88c33cb2170f26b27b8d34e2280a7b532ff (patch) | |
tree | 75875fdb0de7253bee7cf6f488101eea76581204 /app/models | |
parent | 3b29b7c3f65e0c3153fbed0d27f864aaf624a36d (diff) |
Add an option to make alert_tracks run continually, rather than just processing whichever alerts are due right now.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/track_mailer.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb index 89a4f3cad..1b37709b9 100644 --- a/app/models/track_mailer.rb +++ b/app/models/track_mailer.rb @@ -101,6 +101,19 @@ class TrackMailer < ApplicationMailer user.no_xapian_reindex = true user.save! end + return true + end + + def self.alert_tracks_loop + # Run alert_tracks in an endless loop, sleeping when there is nothing to do + while true + sleep_seconds = 1 + while !alert_tracks + sleep sleep_seconds + sleep_seconds *= 2 + sleep_seconds = 300 if sleep_seconds > 300 + end + end end end |