diff options
author | Struan Donald <struan@exo.org.uk> | 2011-09-21 15:04:50 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-09-21 15:04:50 +0100 |
commit | 252ba7c5bf2317b21a84400beeeeb804d1f81f65 (patch) | |
tree | 9d9feb7c788c7acf203f5306593b4a5950e14758 | |
parent | 132a30e6660ee8ec0b3773e20c71c8dbd5e92e0e (diff) |
cache the bing gecode data when we fetch in send-reports
-rwxr-xr-x | bin/send-reports | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/bin/send-reports b/bin/send-reports index 9ab6f8274..fc8ee6e45 100755 --- a/bin/send-reports +++ b/bin/send-reports @@ -90,7 +90,7 @@ while (my $row = $unsent->next) { } if ( $row->used_map ) { - $h{closest_address} = $cobrand->find_closest( $h{latitude}, $h{longitude} ); + $h{closest_address} = $cobrand->find_closest( $h{latitude}, $h{longitude}, $row ); } my (@to, @recips, $template, $areas_info); diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 283de7d75..2e031d740 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -545,10 +545,15 @@ Used by send-reports to attach nearest things to the bottom of the report =cut sub find_closest { - my ( $self, $latitude, $longitude ) = @_; + my ( $self, $latitude, $longitude, $problem ) = @_; my $str = ''; if ( my $j = FixMyStreet::Geocode::Bing::reverse( $latitude, $longitude ) ) { + # cache the bing results for use in alerts + if ( $problem ) { + $problem->geocode( $j ); + $problem->update; + } if ($j->{resourceSets}[0]{resources}[0]{name}) { $str .= sprintf(_("Nearest road to the pin placed on the map (automatically generated by Bing Maps): %s"), $j->{resourceSets}[0]{resources}[0]{name}) . "\n\n"; |