diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-04-20 19:10:10 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-04-20 19:10:10 +0100 |
commit | 4533b28661d6ce6973becf5877e82ca5656c37d2 (patch) | |
tree | e3df319f2d3a3d7a458c5637dee74db02f15bcff /app/models/info_request.rb | |
parent | 8fcafad78e2fba5a09f7ad45542d906e0cdda19b (diff) |
More changes and refactoring to make purges work.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 3a1f4b9f3..9b129e74b 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -453,7 +453,6 @@ public # An annotation (comment) is made def add_comment(body, user) comment = Comment.new - ActiveRecord::Base.transaction do comment.body = body comment.user = user @@ -1043,18 +1042,14 @@ public return ret end - before_save(:mark_view_is_dirty) - def mark_view_is_dirty - self.view_is_dirty = true - self.save! - end - - def self.purge_varnish - for info_request in InfoRequest.find_by_view_is_dirty(true) - url = "/request/#{info_request.url_title}" - purge(url) - info_request.view_is_dirty = true - info_request.save! + before_save :purge_in_cache + def purge_in_cache + if !MySociety::Config.get('VARNISH_HOST').nil? && !self.id.nil? + # we only do this for existing info_requests (new ones have a nil id) + req = PurgeRequest.new(:url => "/request/#{self.url_title}", + :model => self.class.base_class.to_s, + :model_id => self.id) + req.save() end end end |