aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/body_controller.rb17
-rw-r--r--app/models/public_body.rb11
-rw-r--r--spec/models/public_body_spec.rb9
3 files changed, 12 insertions, 25 deletions
diff --git a/app/controllers/body_controller.rb b/app/controllers/body_controller.rb
index e3f4cd8cb..f89eb9d8c 100644
--- a/app/controllers/body_controller.rb
+++ b/app/controllers/body_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: body_controller.rb,v 1.23 2009-03-22 10:31:20 tony Exp $
+# $Id: body_controller.rb,v 1.24 2009-03-22 14:21:56 tony Exp $
class BodyController < ApplicationController
# XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL
@@ -25,11 +25,15 @@ class BodyController < ApplicationController
# Use search query for this so can collapse and paginate easily
# XXX really should just use SQL query here rather than Xapian.
- @xapian_requests = @public_body.xapian_requests
- if (@page > 1)
- @page_desc = " (page " + @page.to_s + ")"
- else
- @page_desc = ""
+ begin
+ @xapian_requests = perform_search([InfoRequestEvent], 'requested_from:' + @public_body.url_name, 'newest', 'request_collapse')
+ if (@page > 1)
+ @page_desc = " (page " + @page.to_s + ")"
+ else
+ @page_desc = ""
+ end
+ rescue
+ @xapian_requests = nil
end
@track_thing = TrackThing.create_track_for_public_body(@public_body)
@@ -82,4 +86,3 @@ class BodyController < ApplicationController
end
end
-
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 54a17af38..b95aa6c88 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -25,7 +25,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: public_body.rb,v 1.137 2009-03-22 10:27:03 tony Exp $
+# $Id: public_body.rb,v 1.138 2009-03-22 14:21:56 tony Exp $
require 'csv'
require 'set'
@@ -148,15 +148,6 @@ class PublicBody < ActiveRecord::Base
return PublicBody.find(old.first.public_body_id)
end
- # Requests made from this body, via Xapian
- def xapian_requests
- begin
- perform_search([InfoRequestEvent], 'requested_from:' + self.url_name, 'newest', 'request_collapse')
- rescue
- return nil
- end
- end
-
# Set the first letter, which is used for faster queries
before_save(:set_first_letter)
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index 38f27cc47..b5b7a2c8c 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -50,7 +50,7 @@ describe PublicBody, "when searching" do
end
describe PublicBody, " when indexing with Xapian" do
- fixtures :public_bodies, :info_request_events, :info_requests
+ fixtures :public_bodies
before(:all) do
rebuild_xapian_index
@@ -68,12 +68,5 @@ describe PublicBody, " when indexing with Xapian" do
xapian_object.results[0][:model].should == public_bodies(:humpadink_public_body)
end
- it "should find requests made to it" do
- @body = public_bodies(:humpadink_public_body)
- xapian_requests = @body.xapian_requests
- xapian_object.results.size.should == 2
- xapian_object.results[0][:model].should == public_bodies(:humpadink_public_body)
- end
-
end