diff options
author | pezholio <pezholio@gmail.com> | 2017-05-24 11:27:52 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-06-20 17:59:29 +0100 |
commit | 27ac8579d461c6d43e10693d2210fcba90b9baac (patch) | |
tree | 3285e166b7a20626b4b72046c6c6d61ed3d320ef /perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm | |
parent | bdd1e1627a1be6d9253ecc4e6904e68948227914 (diff) |
Return Response Priorities as JSON.
This now lets the response priority and defect type handling share the
same code.
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm b/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm index aa9c426f4..89bb4dfd7 100644 --- a/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm +++ b/perllib/FixMyStreet/DB/ResultSet/ResponsePriority.pm @@ -3,20 +3,18 @@ use base 'DBIx::Class::ResultSet'; use strict; use warnings; +use Moo; +use HTML::Entities; -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, - }); +with('FixMyStreet::Roles::ContactExtra'); + +sub join_table { + return 'contact_response_priorities'; +} + +sub map_extras { + my ($rs, @ts) = @_; + return map { { id => $_->id, name => encode_entities($_->name) } } @ts; } 1; |