I forgot to commit the sql script for last commits.
[platal.git] / upgrade / 1.0.1 / merge_issues_geocoding.php
index 8ec2ba3..df98463 100755 (executable)
@@ -9,22 +9,23 @@ $globals->debug = 0; // Do not store backtraces.
 
 print "Tries to geocode addresses (due a bug in the previous release, all addresses must run once again).\n";
 $time = XDB::fetchOneCell('SELECT  COUNT(distinct(pid), jobid)
-                             FROM  profile_addresses');
+                             FROM  profile_addresses
+                            WHERE  accuracy IS NOT NULL AND accuracy > 0');
 $time = ceil($time / 60 / 24);
 print "It will approximately take $time days.\n";
 
 $it = XDB::rawIterator('SELECT  *
                           FROM  profile_addresses
+                         WHERE  accuracy IS NOT NULL AND accuracy > 0
                       ORDER BY  pid, jobid, type, id');
 $total = $it->total();
 $i = 0;
-$j = 0;
 printf("\r%u / %u",  $i, $total);
 $pid = 0;
 $jobid = 0;
 while ($item = $it->next()) {
     $address = new Address($item);
-    $address->format(array(true, true));
+    $address->format(array('requireGeocoding' => true, 'stripGeocoding' => true));
     $address->delete();
     $address->save();
     if (!($pid == $address->pid && $jobid == $address->jobid)) {
@@ -34,13 +35,8 @@ while ($item = $it->next()) {
     }
 
     ++$i;
-    ++$j;
-    if ($j == 10) {
-        $j = 0;
-        printf("\r%u / %u",  $i, $total);
-    }
+    printf("\r%u / %u",  $i, $total);
 }
-printf("\r%u / %u",  $i, $total);
 print "\nGeocoding done.\n\n";
 print "That's all folks!\n";