From 11a73eef1d83cfa3bc3c145de483fa81c25d6216 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 22 Jul 2011 15:55:48 +0100 Subject: Store raw_emails in the filesystem, not in the database. They don't need to be in the database (we never write to them, for example), and they bloat it unecessarily, making backups etc difficult. NOTE: this migration could take a *very* long time. --- app/models/info_request.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index dcef9e5b5..582e7aab9 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -435,11 +435,11 @@ public ActiveRecord::Base.transaction do raw_email = RawEmail.new - raw_email.data = raw_email_data incoming_message.raw_email = raw_email incoming_message.info_request = self - raw_email.save! incoming_message.save! + raw_email.data = raw_email_data + raw_email.save! self.awaiting_description = true self.log_event("response", { :incoming_message_id => incoming_message.id }) -- cgit v1.2.3 From 40979d7966fd148ab73a5c9d1a68c6b57d8f9756 Mon Sep 17 00:00:00 2001 From: David Cabo Date: Sat, 23 Jul 2011 21:21:49 +0200 Subject: catch MissingSourceFile instead of NameError when including custom states, in order to handle the case when file is not present --- app/models/info_request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 582e7aab9..9182b6ae7 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -112,7 +112,7 @@ class InfoRequest < ActiveRecord::Base include InfoRequestCustomStates @@custom_states_loaded = true end - rescue NameError + rescue MissingSourceFile end # only check on create, so existing models with mixed case are allowed -- cgit v1.2.3 From dd58cd35e51c1b98228aae1aa930629e84b6a905 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 25 Jul 2011 09:31:56 +0100 Subject: Don't bother stripping whitespace when checking old requests: it's an expensive operation with a relatively small benefit. --- app/models/info_request.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 582e7aab9..db576b33d 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) -- cgit v1.2.3 From 1e33a67f9e3e282ce83c18127624f74bb5840549 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 25 Jul 2011 15:01:20 +0100 Subject: Rescue NameErrors when attempting to load custom states (for the case where the file exists, but it's empty) --- app/models/info_request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index e6a520fd2..209954b16 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -112,7 +112,7 @@ class InfoRequest < ActiveRecord::Base include InfoRequestCustomStates @@custom_states_loaded = true end - rescue MissingSourceFile + rescue MissingSourceFile, NameError end # only check on create, so existing models with mixed case are allowed -- cgit v1.2.3