diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-06-10 14:56:00 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-06-10 14:56:00 +0100 |
commit | 391ca1c469d93bb2c4798cc15e56fc495b5e80dd (patch) | |
tree | 6bc90fae589de824095e668fbf510ef259935729 /perllib/FixMyStreet/DB/ResultSet/Comment.pm | |
parent | 7c96f8ec61d6eddc211f3f0e71cdb276c6a5f773 (diff) | |
parent | 860383f0de3287b0666d64a3ffff3db3a0f087ae (diff) |
Merge branch 'migrate_to_catalyst' into reportemptyhomes
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Comment.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Comment.pm | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Comment.pm b/perllib/FixMyStreet/DB/ResultSet/Comment.pm new file mode 100644 index 000000000..70f8027aa --- /dev/null +++ b/perllib/FixMyStreet/DB/ResultSet/Comment.pm @@ -0,0 +1,41 @@ +package FixMyStreet::DB::ResultSet::Comment; +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( + { + state => 'confirmed', + created => { '>=', \"ms_current_timestamp()-'7 days'::interval" }, + %{ $restriction }, + }, + { + prefetch => $prefetch, + } + ); +} + +sub summary_count { + my ( $rs, $restriction ) = @_; + + return $rs->search( + $restriction, + { + group_by => ['me.state'], + select => [ 'me.state', { count => 'me.id' } ], + as => [qw/state state_count/], + join => 'problem' + } + ); +} + +1; |