aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm
blob: aa9c426f441e5f6a56b2ca76b7a0f74207f536c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;