aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet/Contact.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-06-10 14:56:00 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-06-10 14:56:00 +0100
commit391ca1c469d93bb2c4798cc15e56fc495b5e80dd (patch)
tree6bc90fae589de824095e668fbf510ef259935729 /perllib/FixMyStreet/DB/ResultSet/Contact.pm
parent7c96f8ec61d6eddc211f3f0e71cdb276c6a5f773 (diff)
parent860383f0de3287b0666d64a3ffff3db3a0f087ae (diff)
Merge branch 'migrate_to_catalyst' into reportemptyhomes
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Contact.pm')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Contact.pm33
1 files changed, 33 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Contact.pm b/perllib/FixMyStreet/DB/ResultSet/Contact.pm
new file mode 100644
index 000000000..6fa6a03a0
--- /dev/null
+++ b/perllib/FixMyStreet/DB/ResultSet/Contact.pm
@@ -0,0 +1,33 @@
+package FixMyStreet::DB::ResultSet::Contact;
+use base 'DBIx::Class::ResultSet';
+
+use strict;
+use warnings;
+
+=head2 not_deleted
+
+ $rs = $rs->not_deleted();
+
+Filter down to not deleted contacts - which have C<deleted> set to false;
+
+=cut
+
+sub not_deleted {
+ my $rs = shift;
+ return $rs->search( { deleted => 0 } );
+}
+
+sub summary_count {
+ my ( $rs, $restriction ) = @_;
+
+ return $rs->search(
+ $restriction,
+ {
+ group_by => ['confirmed'],
+ select => [ 'confirmed', { count => 'id' } ],
+ as => [qw/confirmed confirmed_count/]
+ }
+ );
+}
+
+1;