aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-10-16 17:02:52 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-10-16 17:02:52 +0100
commitdf06903e0c0f3e7f66af787b0acb6fd0a3d3e523 (patch)
treebf841e459d1b68d85aecfebc0aa1bb06752ef041 /bin
parent6e7a34d79217f71076f65b3017eba313b78854cb (diff)
Allow testing override of /reports data.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/update-all-reports14
1 files changed, 12 insertions, 2 deletions
diff --git a/bin/update-all-reports b/bin/update-all-reports
index 4c0e96d31..24192d5be 100755
--- a/bin/update-all-reports
+++ b/bin/update-all-reports
@@ -17,7 +17,10 @@ BEGIN {
}
use FixMyStreet::Script::UpdateAllReports;
+use File::Path ();
+use File::Slurp;
use Getopt::Long::Descriptive;
+use JSON::MaybeXS;
my ($opt, $usage) = describe_options(
'%c %o',
@@ -27,8 +30,15 @@ my ($opt, $usage) = describe_options(
);
print($usage->text), exit if $opt->help;
+my ($data, $filename);
if ($opt->table) {
- FixMyStreet::Script::UpdateAllReports::generate($opt->areas);
+ $data = FixMyStreet::Script::UpdateAllReports::generate($opt->areas);
+ $filename = 'all-reports.json';
} else {
- FixMyStreet::Script::UpdateAllReports::generate_dashboard();
+ $data = FixMyStreet::Script::UpdateAllReports::generate_dashboard();
+ $filename = 'all-reports-dashboard.json';
}
+
+my $json = encode_json($data);
+File::Path::mkpath(FixMyStreet->path_to('../data/')->stringify);
+File::Slurp::write_file(FixMyStreet->path_to("../data/$filename")->stringify, \$json);