Commit | Line | Data |
---|---|---|
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 | ||
5 | require_once 'connect.db.inc.php'; | |
6 | require_once '../../classes/address.php'; | |
7 | ||
8 | $globals->debug = 0; // Do not store backtraces. | |
9 | ||
10 | print "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) | |
12 | FROM profile_addresses'); | |
13 | $time = ceil($time / 60 / 24); | |
14 | print "It will approximately take $time days.\n"; | |
15 | ||
16 | $it = XDB::rawIterator('SELECT * | |
17 | FROM profile_addresses | |
18 | ORDER BY pid, jobid, type, id'); | |
19 | $total = $it->total(); | |
20 | $i = 0; | |
cee99643 SJ |
21 | printf("\r%u / %u", $i, $total); |
22 | $pid = 0; | |
23 | $jobid = 0; | |
24 | while ($item = $it->next()) { | |
25 | $address = new Address($item); | |
739c49b5 | 26 | $address->format(array('requireGeocoding' => true, 'stripGeocoding' => true)); |
cee99643 SJ |
27 | $address->delete(); |
28 | $address->save(); | |
29 | if (!($pid == $address->pid && $jobid == $address->jobid)) { | |
30 | $pid = $address->pid; | |
31 | $jobid = $address->jobid; | |
32 | sleep(60); | |
33 | } | |
34 | ||
35 | ++$i; | |
0db1ca6d | 36 | printf("\r%u / %u", $i, $total); |
cee99643 | 37 | } |
cee99643 SJ |
38 | print "\nGeocoding done.\n\n"; |
39 | print "That's all folks!\n"; | |
40 | ||
41 | /* vim:set et sw=4 sts=4 ts=4: */ | |
42 | ?> |