aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet/Problem.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Problem.pm')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
new file mode 100644
index 000000000..8d798a7c1
--- /dev/null
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -0,0 +1,30 @@
+package FixMyStreet::DB::ResultSet::Problem;
+use base 'DBIx::Class::ResultSet';
+
+use strict;
+use warnings;
+
+sub timeline {
+ my ( $rs, $restriction ) = @_;
+
+ my $prefetch =
+ FixMyStreet::App->model('DB')->schema->storage->sql_maker->quote_char ?
+ [ qw/user/ ] :
+ [];
+
+ return $rs->search(
+ {
+ -or => {
+ created => { '>=', \"ms_current_timestamp()-'7 days'::interval" },
+ confirmed => { '>=', \"ms_current_timestamp()-'7 days'::interval" },
+ whensent => { '>=', \"ms_current_timestamp()-'7 days'::interval" },
+ %{ $restriction },
+ }
+ },
+ {
+ prefetch => $prefetch,
+ }
+ );
+}
+
+1;