aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-01-08 14:47:29 +0000
committerMatthew Somerville <matthew@mysociety.org>2020-01-09 17:31:45 +0000
commit65ca47eda62a45bf081128b507c94c7b18a77a00 (patch)
treeee36b2be8b543cab09ecc748a7fad022eb0eb21b
parent73a6134c4bb8c29e2755cf7241524dc0538a4a6a (diff)
[TfL] Ignore reports updated over three years ago.
-rw-r--r--perllib/FixMyStreet/Cobrand/TfL.pm20
-rw-r--r--t/cobrand/tfl.t10
2 files changed, 30 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm
index e26dfee65..eedbc41b5 100644
--- a/perllib/FixMyStreet/Cobrand/TfL.pm
+++ b/perllib/FixMyStreet/Cobrand/TfL.pm
@@ -107,6 +107,26 @@ sub report_age { '6 weeks' }
# We don't want any reports made before the go-live date visible
sub cut_off_date { '2019-12-09 12:00' }
+sub problems_restriction {
+ my ($self, $rs) = @_;
+ return $rs if FixMyStreet->staging_flag('skip_checks');
+ $rs = $self->next::method($rs);
+ my $table = ref $rs eq 'FixMyStreet::DB::ResultSet::Nearby' ? 'problem' : 'me';
+ $rs = $rs->search({
+ "$table.lastupdate" => { '>=', \"now() - '3 years'::interval" }
+ });
+ return $rs;
+}
+
+sub problems_sql_restriction {
+ my ($self, $item_table) = @_;
+ my $q = $self->next::method($item_table);
+ if ($item_table ne 'comment') {
+ $q .= " AND lastupdate >= now() - '3 years'::interval";
+ }
+ return $q;
+}
+
sub password_expiry {
return if FixMyStreet->test_mode;
# uncoverable statement
diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t
index 33506e8c4..e1990c946 100644
--- a/t/cobrand/tfl.t
+++ b/t/cobrand/tfl.t
@@ -556,6 +556,16 @@ subtest 'check report age on /around' => sub {
});
};
+subtest 'check report age in general' => sub {
+ my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'});
+ $report->update({ state => 'confirmed' });
+ $mech->get_ok('/report/' . $report->id);
+ $report->update({ lastupdate => \"current_timestamp-'4 years'::interval" });
+ $mech->get('/report/' . $report->id);
+ is $mech->res->code, 404;
+ $report->update({ lastupdate => \"current_timestamp" });
+};
+
subtest 'TfL admin allows inspectors to be assigned to borough areas' => sub {
$mech->log_in_ok($superuser->email);