aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-05-04 11:53:36 +0100
committerSeb Bacon <seb.bacon@gmail.com>2012-05-04 11:53:36 +0100
commitb0b1aebb371211e0deb5e9eac600817e90f83301 (patch)
tree833edab5fbea766670b9e707045ebae69f32bd59 /app/models/info_request.rb
parentf3069a3ea4e1209115334f6455c20ed6802fbd57 (diff)
Don't ever create more than one entry for each URL that we want Varnish to purge.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 78121f5ea..e570150bb 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -1050,9 +1050,12 @@ public
if !MySociety::Config.get('VARNISH_HOST').nil? && !self.id.nil?
# we only do this for existing info_requests (new ones have a nil id)
path = url_for(:controller => 'request', :action => 'show', :url_title => self.url_title, :only_path => true, :locale => :none)
- req = PurgeRequest.new(:url => path,
- :model => self.class.base_class.to_s,
- :model_id => self.id)
+ req = PurgeRequest.find_by_url(path)
+ if req.nil?
+ req = PurgeRequest.new(:url => path,
+ :model => self.class.base_class.to_s,
+ :model_id => self.id)
+ end
req.save()
end
end