aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-05-02 17:05:43 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-05-08 15:32:12 +0100
commit505953fc71a6142826e1e5743a0a3dc18e306748 (patch)
tree79bb4371dee529c70a98ef8160da3d412a161d0f /perllib
parentba16e095260993d814e6fb603a7d405d08a4ecb9 (diff)
Remove needless category mappings.
Both filter categories and new report category lists went through mappings to different data structures, which doesn't seem to be needed.
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm5
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm1
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm13
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm1
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm2
6 files changed, 11 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index a923a3407..535a8d08e 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -1088,7 +1088,7 @@ sub categories_for_point : Private {
# Remove the "Pick a category" option
shift @{$c->stash->{category_options}} if @{$c->stash->{category_options}};
- $c->stash->{categories_hash} = { map { $_->{name} => 1 } @{$c->stash->{category_options}} };
+ $c->stash->{categories_hash} = { map { $_->category => 1 } @{$c->stash->{category_options}} };
}
sub templates : Path('templates') : Args(0) {
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index bdf381294..184d61f4f 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -228,7 +228,7 @@ sub check_and_stash_category : Private {
my @bodies = $c->model('DB::Body')->active->for_areas(keys %$all_areas)->all;
my %bodies = map { $_->id => $_ } @bodies;
- my @contacts = $c->model('DB::Contact')->not_deleted->search(
+ my @categories = $c->model('DB::Contact')->not_deleted->search(
{
body_id => [ keys %bodies ],
},
@@ -238,9 +238,8 @@ sub check_and_stash_category : Private {
distinct => 1
}
)->all;
- my @categories = map { { name => $_->category, value => $_->category_display } } @contacts;
$c->stash->{filter_categories} = \@categories;
- my %categories_mapped = map { $_->{name} => 1 } @categories;
+ my %categories_mapped = map { $_->category => 1 } @categories;
my $categories = [ $c->get_param_list('filter_category', 1) ];
my %valid_categories = map { $_ => 1 } grep { $_ && $categories_mapped{$_} } @$categories;
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index 1693766ba..f6ba9a6ee 100644
--- a/perllib/FixMyStreet/App/Controller/My.pm
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -163,7 +163,6 @@ sub setup_page_data : Private {
distinct => 1,
order_by => [ 'category' ],
} )->all;
- @categories = map { { name => $_->category, value => $_->category_display } } @categories;
$c->stash->{filter_categories} = \@categories;
$c->stash->{page} = 'my';
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 3a8362b5b..574ef0390 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -666,7 +666,7 @@ sub setup_categories_and_bodies : Private {
$bodies_to_list{ $contact->body_id } = $contact->body;
unless ( $seen{$contact->category} ) {
- push @category_options, { name => $contact->category, value => $contact->category_display, group => $contact->get_extra_metadata('group') || '' };
+ push @category_options, $contact;
my $metas = $contact->get_metadata_for_input;
$category_extras{$contact->category} = $metas if @$metas;
@@ -679,15 +679,15 @@ sub setup_categories_and_bodies : Private {
$non_public_categories{ $contact->category } = 1 if $contact->non_public;
}
- $seen{$contact->category} = $contact->category_display;
+ $seen{$contact->category} = $contact;
}
if (@category_options) {
# If there's an Other category present, put it at the bottom
@category_options = (
- { name => _('-- Pick a category --'), value => _('-- Pick a category --'), group => '' },
- grep { $_->{name} ne _('Other') } @category_options );
- push @category_options, { name => _('Other'), value => $seen{_('Other')}, group => _('Other') } if $seen{_('Other')};
+ { category => _('-- Pick a category --'), category_display => _('-- Pick a category --'), group => '' },
+ grep { $_->category ne _('Other') } @category_options );
+ push @category_options, $seen{_('Other')} if $seen{_('Other')};
}
$c->cobrand->call_hook(munge_category_list => \@category_options, \@contacts, \%category_extras);
@@ -711,7 +711,8 @@ sub setup_categories_and_bodies : Private {
if ( $c->cobrand->call_hook('enable_category_groups') ) {
my %category_groups = ();
for my $category (@category_options) {
- push @{$category_groups{$category->{group}}}, $category;
+ my $group = $category->{group} // $category->get_extra_metadata('group') // '';
+ push @{$category_groups{$group}}, $category;
}
my @category_groups = ();
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 3aa24c2db..3b9ceaebc 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -160,7 +160,6 @@ sub ward : Path : Args(2) {
distinct => 1,
order_by => [ 'category' ],
} )->all;
- @categories = map { { name => $_->category, value => $_->category_display } } @categories;
$c->stash->{filter_categories} = \@categories;
$c->stash->{filter_category} = { map { $_ => 1 } $c->get_param_list('filter_category', 1) };
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 453300cd5..1acbdaf71 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -499,7 +499,7 @@ sub category_options {
my ($self, $c) = @_;
my @categories = $c->model('DB::Contact')->not_deleted->all;
$c->stash->{category_options} = [ map { {
- name => $_->category, value => $_->category,
+ category => $_->category, category_display => $_->category,
abbreviation => $_->get_extra_metadata('abbreviation'),
} } @categories ];
}