diff options
author | Mark Longair <mhl@pobox.com> | 2013-08-20 10:04:54 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-08-20 12:11:45 +0100 |
commit | b75d79b08227192b75e4f3b24ce4e762f4286ef9 (patch) | |
tree | 6a9645f51e17da0048f92b9eb54f8465cd498a13 | |
parent | 493c1a270b02bf1cd6030e56babefcca89a81595 (diff) |
Add a config option to enable the public body statistics page
-rw-r--r-- | app/controllers/public_body_controller.rb | 4 | ||||
-rw-r--r-- | config/general.yml-example | 4 | ||||
-rw-r--r-- | lib/configuration.rb | 1 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 1 |
4 files changed, 10 insertions, 0 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index b5d4ede90..ebf159d79 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -151,6 +151,10 @@ class PublicBodyController < ApplicationController end def statistics + unless AlaveteliConfiguration::public_body_statistics_page + raise ActiveRecord::RecordNotFound.new("Page not enabled") + end + per_graph = 10 minimum_requests = AlaveteliConfiguration::minimum_requests_for_statistics # Make sure minimum_requests is > 0 to avoid division-by-zero diff --git a/config/general.yml-example b/config/general.yml-example index e90674b0f..37b0c2fc9 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -193,6 +193,10 @@ MTA_LOG_TYPE: "exim" # successful. DONATION_URL: "http://www.mysociety.org/donate/" +# If you set this to 'true' then a page of statistics on the +# performance of public bodies will be available: +PUBLIC_BODY_STATISTICS_PAGE: false + # The page of statistics for public bodies will only consider public # bodies that have had at least this number of requests: MINIMUM_REQUESTS_FOR_STATISTICS: 50 diff --git a/lib/configuration.rb b/lib/configuration.rb index bf80f87e1..d6fd8765f 100644 --- a/lib/configuration.rb +++ b/lib/configuration.rb @@ -48,6 +48,7 @@ module AlaveteliConfiguration :MTA_LOG_TYPE => 'exim', :NEW_RESPONSE_REMINDER_AFTER_DAYS => [3, 10, 24], :OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS => '', + :PUBLIC_BODY_STATISTICS_PAGE => false, :RAW_EMAILS_LOCATION => 'files/raw_emails', :READ_ONLY => '', :RECAPTCHA_PRIVATE_KEY => 'x', diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 87544b96a..92130f3d0 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -213,6 +213,7 @@ describe PublicBodyController, "when showing public body statistics" do it "should render the right template with the right data" do config = MySociety::Config.load_default() config['MINIMUM_REQUESTS_FOR_STATISTICS'] = 1 + config['PUBLIC_BODY_STATISTICS_PAGE'] = true get :statistics response.should render_template('public_body/statistics') # There are 5 different graphs we're creating at the moment. |