diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-06-16 12:15:03 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-06-16 12:15:03 +0100 |
commit | 4a7912b97c75d8934bbab33532f0b6ac1e86e47f (patch) | |
tree | 3645cd9bd55c77b71adbe7a8fc74bcc58202ba01 /perllib | |
parent | 4cbadaa9cd86ff3c0a82ccb696d115c2496b287a (diff) |
Generate /reports data on cron.
Diffstat (limited to 'perllib')
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Questionnaire.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 14 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tokens.pm | 2 |
3 files changed, 16 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index 658d32e74..5506e2dbd 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -44,7 +44,7 @@ sub load_questionnaire : Private { my $problem_url = $c->uri_for( "/report/$problem_id" ); my $contact_url = $c->uri_for( "/contact" ); $c->stash->{message} = sprintf(_("You have already answered this questionnaire. If you have a question, please <a href='%s'>get in touch</a>, or <a href='%s'>view your problem</a>.\n"), $contact_url, $problem_url); - $c->stash->{template} = 'questionnaire/error.html'; + $c->stash->{template} = 'errors/generic.html'; $c->detach; } @@ -95,7 +95,7 @@ sub missing_problem : Private { my ( $self, $c ) = @_; $c->stash->{message} = _("I'm afraid we couldn't locate your problem in the database.\n"); - $c->stash->{template} = 'questionnaire/error.html'; + $c->stash->{template} = 'errors/generic.html'; } sub submit_creator_fixed : Private { diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 850433d3c..e1983c855 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -2,6 +2,7 @@ package FixMyStreet::App::Controller::Reports; use Moose; use namespace::autoclean; +use File::Slurp; use List::MoreUtils qw(zip); use POSIX qw(strcoll); use mySociety::MaPit; @@ -51,7 +52,18 @@ sub index : Path : Args(0) { my @keys = sort { strcoll($areas_info->{$a}{name}, $areas_info->{$b}{name}) } keys %$areas_info; $c->stash->{areas_info_sorted} = [ map { $areas_info->{$_} } @keys ]; - $c->forward( 'load_and_group_problems' ); + eval { + my $data = File::Slurp::read_file( + FixMyStreet->path_to( '../data/all-reports.json' )->stringify + ); + my $j = JSON->new->utf8->decode($data); + $c->stash->{fixed} = $j->{fixed}; + $c->stash->{open} = $j->{open}; + }; + if ($@) { + $c->stash->{message} = _("There was a problem showing the All Reports page. Please try again later."); + $c->stash->{template} = 'errors/generic.html'; + } } =head2 index diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index c75fcc9ee..111508e60 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -158,7 +158,7 @@ sub load_questionnaire_id : Private { my ( $self, $c, $token_code ) = @_; # Set up error handling - $c->stash->{error_template} = 'questionnaire/error.html'; + $c->stash->{error_template} = 'errors/generic.html'; $c->stash->{message} = _("I'm afraid we couldn't validate that token. If you've copied the URL from an email, please check that you copied it exactly.\n"); my $auth_token = $c->forward( 'load_auth_token', [ $token_code, 'questionnaire' ] ); |