aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet/Alert.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-06-07 17:34:08 +0100
committerStruan Donald <struan@exo.org.uk>2011-06-07 17:34:08 +0100
commit5813d21b9ac8b358a557ab67722e8b54c769b663 (patch)
treed8d81597e1abf13855d27dd1b3a5353ca2f3240c /perllib/FixMyStreet/DB/ResultSet/Alert.pm
parent0f7de6563d4c96fa1ec9c429cca7e42259e25422 (diff)
move summary count fetching out to result sets
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Alert.pm')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Alert.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Alert.pm b/perllib/FixMyStreet/DB/ResultSet/Alert.pm
index 62e6120e4..5848265f1 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Alert.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Alert.pm
@@ -35,4 +35,16 @@ sub timeline_disabled {
);
}
+sub summary_count {
+ my ( $rs, $restriction ) = @_;
+
+ return $rs->search(
+ $restriction,
+ {
+ group_by => ['confirmed'],
+ select => [ 'confirmed', { count => 'id' } ],
+ as => [qw/confirmed confirmed_count/]
+ }
+ );
+}
1;