aboutsummaryrefslogtreecommitdiffstats
path: root/bin/populate_bing_cache
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-11-28 18:30:50 +0000
committerStruan Donald <struan@exo.org.uk>2011-11-28 18:30:50 +0000
commitb8813503550d4adc8c88a0ee0f15b23128274e01 (patch)
tree0bf05a674a6f0f6569aff372bd91b2e8003d1766 /bin/populate_bing_cache
parent7b84603eba13109bee0d39b2bb48d6e55371f8ec (diff)
only look fetch what we need and provide some feedback
Diffstat (limited to 'bin/populate_bing_cache')
-rwxr-xr-x[-rw-r--r--]bin/populate_bing_cache37
1 files changed, 32 insertions, 5 deletions
diff --git a/bin/populate_bing_cache b/bin/populate_bing_cache
index f61b4a4bd..bb5d4e77a 100644..100755
--- a/bin/populate_bing_cache
+++ b/bin/populate_bing_cache
@@ -9,17 +9,44 @@ use Data::Dumper;
use FixMyStreet::App;
use FixMyStreet::Geocode::Bing;
-my $reports = FixMyStreet::App->model('DB::Problem')->search( {geocode
- => undef }, { select => [qw/id geocode confirmed latitude longitude/] } );
+my $reports = FixMyStreet::App->model('DB::Problem')->search(
+ {
+ geocode => undef,
+ confirmed => { '!=', undef },
+ latitude => { '!=', 0 },
+ longitude => { '!=', 0 },
+ },
+ { select => [qw/id geocode confirmed latitude longitude/] }
+);
+
+my $num_reports = $reports->count();
+print "Found $num_reports lacking geocode information\n";
+
+my $time_to_do = ( $num_reports * 10 ) / 60 / 60;
+if ( $time_to_do > 24 ) {
+ my $days = $time_to_do / 24;
+ my $hours = $time_to_do % 24;
+ printf( "Should take %d days and %d hours to finish\n", $days, $hours );
+} elsif ( $time_to_do < 1 ) {
+ printf( "Should take %d minutes to finish\n", $time_to_do * 60 );
+} else {
+ my $mins = ( $num_reports * 10 ) / 60 % 60;
+ printf( "Should take %d hours and %d minutes to finish\n", $time_to_do, $mins );
+}
while ( my $report = $reports->next ) {
+ $num_reports--;
next unless $report->latitude && $report->longitude;
- print $report->id . "\n";
+ next if $report->geocode;
- my $j = FixMyStreet::Geocode::Bing::reverse( $report->latitude, $report->longitude );
+ my $j = FixMyStreet::Geocode::Bing::reverse( $report->latitude,
+ $report->longitude );
- $report->geocode( $j );
+ $report->geocode($j);
$report->update;
+ print "$num_reports left to populate\n" unless $num_reports % 100;
sleep 10;
}
+
+print "done\n";