aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/track_mailer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/track_mailer.rb')
-rw-r--r--app/models/track_mailer.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb
index 5e1c31974..0c053c4ad 100644
--- a/app/models/track_mailer.rb
+++ b/app/models/track_mailer.rb
@@ -40,10 +40,11 @@ class TrackMailer < ApplicationMailer
# Useful query to run by hand to see how many alerts are due:
# User.find(:all, :conditions => [ "last_daily_track_email < ?", Time.now - 1.day ]).size
def self.alert_tracks
+ done_something = false
now = Time.now()
users = User.find(:all, :conditions => [ "last_daily_track_email < ?", now - 1.day ])
if users.empty?
- return false
+ return done_something
end
for user in users
next if !user.should_be_emailed?
@@ -93,7 +94,11 @@ class TrackMailer < ApplicationMailer
# If we have anything to send, then send everything for the user in one mail
if email_about_things.size > 0
# Send the email
+
+ previous_locale = I18n.locale
+ I18n.locale = user.get_locale
TrackMailer.deliver_event_digest(user, email_about_things)
+ I18n.locale = previous_locale
end
# Record that we've now sent those alerts to that user
@@ -112,8 +117,9 @@ class TrackMailer < ApplicationMailer
user.last_daily_track_email = now
user.no_xapian_reindex = true
user.save!
+ done_something = true
end
- return true
+ return done_something
end
def self.alert_tracks_loop