diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 17 | ||||
-rw-r--r-- | app/models/info_request.rb | 9 | ||||
-rw-r--r-- | app/models/raw_email.rb | 1 | ||||
-rw-r--r-- | app/models/track_mailer.rb | 6 |
4 files changed, 17 insertions, 16 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 405327952..fe9ed7ec7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -46,12 +46,17 @@ class ApplicationController < ActionController::Base # egrep "CONSUME MEMORY: [0-9]{7} KB" production.log around_filter :record_memory def record_memory - File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/) - rss_before_action = $1.to_i - yield - File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/) - rss_after_action = $1.to_i - logger.info("PID: #{Process.pid}\tCONSUME MEMORY: #{rss_after_action - rss_before_action} KB\tNow: #{rss_after_action} KB\t#{request.url}") + record_memory = MySociety::Config.get('DEBUG_RECORD_MEMORY', false) + if record_memory + File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/) + rss_before_action = $1.to_i + yield + File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/) + rss_after_action = $1.to_i + logger.info("PID: #{Process.pid}\tCONSUME MEMORY: #{rss_after_action - rss_before_action} KB\tNow: #{rss_after_action} KB\t#{request.url}") + else + yield + end end # Set cookie expiry according to "remember me" checkbox, as per "An easier diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 9182b6ae7..e6a520fd2 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -347,14 +347,7 @@ public # XXX this *should* also check outgoing message joined to is an initial # request (rather than follow up) def InfoRequest.find_by_existing_request(title, public_body_id, body) - # XXX can add other databases here which have regexp_replace - if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" - # Exclude spaces from the body comparison using regexp_replace - return InfoRequest.find(:first, :conditions => [ "title = ? and public_body_id = ? and regexp_replace(outgoing_messages.body, '[[:space:]]', '', 'g') = regexp_replace(?, '[[:space:]]', '', 'g')", title, public_body_id, body ], :include => [ :outgoing_messages ] ) - else - # For other databases (e.g. SQLite) not the end of the world being space-sensitive for this check - return InfoRequest.find(:first, :conditions => [ "title = ? and public_body_id = ? and outgoing_messages.body = ?", title, public_body_id, body ], :include => [ :outgoing_messages ] ) - end + return InfoRequest.find(:first, :conditions => [ "title = ? and public_body_id = ? and outgoing_messages.body = ?", title, public_body_id, body ], :include => [ :outgoing_messages ] ) end def find_existing_outgoing_message(body) diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb index 7a57399d5..4e1a69456 100644 --- a/app/models/raw_email.rb +++ b/app/models/raw_email.rb @@ -6,7 +6,6 @@ # id :integer not null, primary key # data_text :text # data_binary :binary -# - prepared to 277k. # models/raw_email.rb: # The fat part of models/incoming_message.rb diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb index 1b37709b9..6901a834d 100644 --- a/app/models/track_mailer.rb +++ b/app/models/track_mailer.rb @@ -26,7 +26,11 @@ class TrackMailer < ApplicationMailer @body = { :user => user, :email_about_things => email_about_things, :unsubscribe_url => unsubscribe_url } end - # Send email alerts for tracked things. + # Send email alerts for tracked things. Never more than one email + # a day, nor about events which are more than a week old, nor + # events about which emails have been sent within the last two + # weeks. + # 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 |