diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-06-09 00:59:23 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-06-09 00:59:23 +0100 |
commit | ba0bd42476b93908529f63bb8b71135ebf7a86ca (patch) | |
tree | d9376ff3c5b8b6f75e3ab92c7ec5d1cbc99f553f /perllib/FixMyStreet/App/Controller/Around.pm | |
parent | 8756c80504ceb6275f637c75fdcf1a047970d6ff (diff) |
Move the tricky nearby DB call to its own Result/ResultSet, and move more functions.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Around.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index 1e06beef1..370fe7b89 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -182,13 +182,17 @@ sub display_location : Private { # create a list of all the pins my @pins; unless ($c->req->param('no_pins')) { - @pins = map { { - latitude => $_->{latitude}, - longitude => $_->{longitude}, - colour => $_->{state} eq 'fixed' ? 'green' : 'red', - id => $_->{id}, - title => $_->{title}, - } } @$on_map_all, @$around_map; + @pins = map { + # Here we might have a DB::Problem or a DB::Nearby, we always want the problem. + my $p = (ref $_ eq 'FixMyStreet::App::Model::DB::Nearby') ? $_->problem : $_; + { + latitude => $p->latitude, + longitude => $p->longitude, + colour => $p->state eq 'fixed' ? 'green' : 'red', + id => $p->id, + title => $p->title, + } + } @$on_map_all, @$around_map; } { # FIXME - ideally this indented code should be in the templates |