Adds field for sports and hobbies (Closes #1446).
[platal.git] / upgrade / 1.0.1 / merge_issues_geocoding.php
CommitLineData
cee99643
SJ
1#!/usr/bin/php5
2<?php
3// WARNING: this script takes a few weeks to be executed completly, thus run it into a screen.
4
5require_once 'connect.db.inc.php';
6require_once '../../classes/address.php';
7
8$globals->debug = 0; // Do not store backtraces.
9
10print "Tries to geocode addresses (due a bug in the previous release, all addresses must run once again).\n";
11$time = XDB::fetchOneCell('SELECT COUNT(distinct(pid), jobid)
7ea0c31b
SJ
12 FROM profile_addresses
13 WHERE accuracy IS NOT NULL AND accuracy > 0');
cee99643
SJ
14$time = ceil($time / 60 / 24);
15print "It will approximately take $time days.\n";
16
17$it = XDB::rawIterator('SELECT *
18 FROM profile_addresses
7ea0c31b 19 WHERE accuracy IS NOT NULL AND accuracy > 0
cee99643
SJ
20 ORDER BY pid, jobid, type, id');
21$total = $it->total();
22$i = 0;
cee99643
SJ
23printf("\r%u / %u", $i, $total);
24$pid = 0;
25$jobid = 0;
26while ($item = $it->next()) {
27 $address = new Address($item);
739c49b5 28 $address->format(array('requireGeocoding' => true, 'stripGeocoding' => true));
cee99643
SJ
29 $address->delete();
30 $address->save();
31 if (!($pid == $address->pid && $jobid == $address->jobid)) {
32 $pid = $address->pid;
33 $jobid = $address->jobid;
34 sleep(60);
35 }
36
37 ++$i;
0db1ca6d 38 printf("\r%u / %u", $i, $total);
cee99643 39}
cee99643
SJ
40print "\nGeocoding done.\n\n";
41print "That's all folks!\n";
42
43/* vim:set et sw=4 sts=4 ts=4: */
44?>