aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Script
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-05-15 13:05:17 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-05-23 18:55:10 +0100
commit15678f4923a3395fc3bb4b6c6cc82cf38d09021e (patch)
treea8ae0b8b0a1d48f79e41fcaedcd5dd155620e8ec /perllib/FixMyStreet/Script
parenteb58ad65f8b25be9dc4321ca5914ad1d89f8bf3a (diff)
Add ability to close updates on reports.
The inactive report script can mark matched reports as closed for updates. This removes the update form and signing up for updates from a report page.
Diffstat (limited to 'perllib/FixMyStreet/Script')
-rw-r--r--perllib/FixMyStreet/Script/Inactive.pm24
1 files changed, 24 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Script/Inactive.pm b/perllib/FixMyStreet/Script/Inactive.pm
index 3c6be9901..0468d2a52 100644
--- a/perllib/FixMyStreet/Script/Inactive.pm
+++ b/perllib/FixMyStreet/Script/Inactive.pm
@@ -11,6 +11,7 @@ use FixMyStreet::DB;
use FixMyStreet::Email;
has anonymize => ( is => 'ro' );
+has close => ( is => 'ro' );
has email => ( is => 'ro' );
has verbose => ( is => 'ro' );
has dry_run => ( is => 'ro' );
@@ -53,6 +54,29 @@ sub reports {
my $self = shift;
say "DRY RUN" if $self->dry_run;
+ $self->anonymize_reports if $self->anonymize;
+ $self->close_updates if $self->close;
+}
+
+sub close_updates {
+ my $self = shift;
+
+ my $problems = FixMyStreet::DB->resultset("Problem")->search({
+ lastupdate => { '<', interval($self->close) },
+ state => [ FixMyStreet::DB::Result::Problem->closed_states(), FixMyStreet::DB::Result::Problem->fixed_states() ],
+ extra => [ undef, { -not_like => '%closed_updates%' } ],
+ });
+
+ while (my $problem = $problems->next) {
+ say "Closing updates on problem #" . $problem->id if $self->verbose;
+ next if $self->dry_run;
+ $problem->set_extra_metadata( closed_updates => 1 );
+ $problem->update;
+ }
+}
+
+sub anonymize_reports {
+ my $self = shift;
# Need to look though them all each time, in case any new updates/alerts
my $problems = FixMyStreet::DB->resultset("Problem")->search({