aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm22
1 files changed, 22 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm b/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm
new file mode 100644
index 000000000..aa9c426f4
--- /dev/null
+++ b/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm
@@ -0,0 +1,22 @@
+package FixMyStreet::DB::ResultSet::ResponsePriority;
+use base 'DBIx::Class::ResultSet';
+
+use strict;
+use warnings;
+
+sub for_bodies {
+ my ($rs, $bodies, $category) = @_;
+ my $attrs = {
+ 'me.body_id' => $bodies,
+ };
+ if ($category) {
+ $attrs->{'contact.category'} = [ $category, undef ];
+ }
+ $rs->search($attrs, {
+ order_by => 'name',
+ join => { 'contact_response_priorities' => 'contact' },
+ distinct => 1,
+ });
+}
+
+1;