diff options
author | Marius Halden <marius.h@lden.org> | 2015-10-27 13:27:03 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2015-10-27 13:27:03 +0100 |
commit | 4fb5331abd2fa4c89ebeb89bc92a245fadd0aa19 (patch) | |
tree | 23632b448612e3845a6e8b1aed6490151395de2a /perllib/FixMyStreet/DB/ResultSet/Comment.pm | |
parent | e609613b5041a15491417eaa9ae129dd1e7531dd (diff) | |
parent | ac39951581a0eefe069c8a707bb89977227d0bce (diff) |
Merge tag 'v1.7' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Comment.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Comment.pm | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Comment.pm b/perllib/FixMyStreet/DB/ResultSet/Comment.pm index 70f8027aa..1b6afb819 100644 --- a/perllib/FixMyStreet/DB/ResultSet/Comment.pm +++ b/perllib/FixMyStreet/DB/ResultSet/Comment.pm @@ -4,19 +4,24 @@ use base 'DBIx::Class::ResultSet'; use strict; use warnings; +sub to_body { + my ($rs, $body_restriction) = @_; + return FixMyStreet::DB::ResultSet::Problem::to_body($rs, $body_restriction); +} + + sub timeline { - my ( $rs, $restriction ) = @_; + my ( $rs, $body_restriction ) = @_; my $prefetch = FixMyStreet::App->model('DB')->schema->storage->sql_maker->quote_char ? [ qw/user/ ] : []; - return $rs->search( + return $rs->to_body($body_restriction)->search( { state => 'confirmed', - created => { '>=', \"ms_current_timestamp()-'7 days'::interval" }, - %{ $restriction }, + created => { '>=', \"current_timestamp-'7 days'::interval" }, }, { prefetch => $prefetch, @@ -25,17 +30,18 @@ sub timeline { } sub summary_count { - my ( $rs, $restriction ) = @_; + my ( $rs, $body_restriction ) = @_; - return $rs->search( - $restriction, - { - group_by => ['me.state'], - select => [ 'me.state', { count => 'me.id' } ], - as => [qw/state state_count/], - join => 'problem' - } - ); + my $params = { + group_by => ['me.state'], + select => [ 'me.state', { count => 'me.id' } ], + as => [qw/state state_count/], + }; + if ($body_restriction) { + $rs = $rs->to_body($body_restriction); + $params->{join} = 'problem'; + } + return $rs->search(undef, $params); } 1; |