aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm15
-rwxr-xr-xperllib/FixMyStreet/Script/UpdateAllReports.pm14
2 files changed, 10 insertions, 19 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 187dfb299..c30c113ec 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -2,9 +2,9 @@ package FixMyStreet::App::Controller::Reports;
use Moose;
use namespace::autoclean;
-use File::Slurp;
use JSON::MaybeXS;
use List::MoreUtils qw(any);
+use Path::Tiny;
use POSIX qw(strcoll);
use RABX;
use mySociety::MaPit;
@@ -83,16 +83,15 @@ sub index : Path : Args(0) {
$c->stash->{any_empty_bodies} = any { $_->get_column('area_count') == 0 } @bodies;
my $dashboard = eval {
- my $data = File::Slurp::read_file(
- FixMyStreet->path_to( '../data/all-reports-dashboard.json' )->stringify
- );
- $c->stash(decode_json($data));
+ my $data = FixMyStreet->config('TEST_DASHBOARD_DATA');
+ unless ($data) {
+ $data = decode_json(path(FixMyStreet->path_to('../data/all-reports-dashboard.json'))->slurp_utf8);
+ }
+ $c->stash($data);
return 1;
};
my $table = eval {
- my $data = File::Slurp::read_file(
- FixMyStreet->path_to( '../data/all-reports.json' )->stringify
- );
+ my $data = path(FixMyStreet->path_to('../data/all-reports.json'))->slurp_utf8;
$c->stash(decode_json($data));
return 1;
};
diff --git a/perllib/FixMyStreet/Script/UpdateAllReports.pm b/perllib/FixMyStreet/Script/UpdateAllReports.pm
index 1bd069ee8..f459b7b12 100755
--- a/perllib/FixMyStreet/Script/UpdateAllReports.pm
+++ b/perllib/FixMyStreet/Script/UpdateAllReports.pm
@@ -6,9 +6,6 @@ use warnings;
use FixMyStreet;
use FixMyStreet::DB;
-use File::Path ();
-use File::Slurp;
-use JSON::MaybeXS;
use List::MoreUtils qw(zip);
use List::Util qw(sum);
@@ -81,13 +78,10 @@ sub generate {
}
}
- my $body = encode_json( {
+ return {
fixed => \%fixed,
open => \%open,
- } );
-
- File::Path::mkpath( FixMyStreet->path_to( '../data/' )->stringify );
- File::Slurp::write_file( FixMyStreet->path_to( '../data/all-reports.json' )->stringify, \$body );
+ };
}
sub end_period {
@@ -247,9 +241,7 @@ sub generate_dashboard {
}
$data{other_categories} = $last_seven_days;
- my $body = encode_json( \%data );
- File::Path::mkpath( FixMyStreet->path_to( '../data/' )->stringify );
- File::Slurp::write_file( FixMyStreet->path_to( '../data/all-reports-dashboard.json' )->stringify, \$body );
+ return \%data;
}
sub stuff_by_day_or_year {