diff options
| author | franck cuny <franck@lumberjaph.net> | 2010-02-12 16:41:02 +0100 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2010-02-12 16:41:02 +0100 |
| commit | d2551c9cc2e637835876fec5e9cb58f9e9f2061c (patch) | |
| tree | 3f1ab54705e1a21d3978cd0da73ed8c12137074f /clean-country.pl | |
| parent | Merge branch 'master' of lj:github-explorer (diff) | |
| download | github-explorer-d2551c9cc2e637835876fec5e9cb58f9e9f2061c.tar.gz | |
wip
Diffstat (limited to 'clean-country.pl')
| -rw-r--r-- | clean-country.pl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/clean-country.pl b/clean-country.pl new file mode 100644 index 0000000..9fb0b5c --- /dev/null +++ b/clean-country.pl @@ -0,0 +1,34 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use lib ('lib'); +use 5.010; +use Geo::GeoNames; +use githubexplorer::Schema; +use YAML::Syck; + +my $conf = LoadFile(shift); + +my $schema = githubexplorer::Schema->connect(@{$conf->{connect_info}}); + +my $profiles = $schema->resultset('Profiles')->search({id => {'>' => 55781}, location => {'!=' => + undef}, location => {'!=' => ''}}); + +my $geo = Geo::GeoNames->new(); + +while (my $pr = $profiles->next) { + next if $pr->location =~ /^http/; + next if $pr->country; + next if $pr->location =~ /earth/i; + say "-> process ".$pr->login." with ".$pr->location; + my $result = $geo->search( q => $pr->location, maxRows => 1 ); + my $res = shift @$result; + if ($res) { + eval { + $pr->update({city => $res->{name}, country => $res->{countryName}}); + }; + next if $@; + say "** fix with ".$pr->city . " in ".$pr->country; + } + sleep(1); +}
\ No newline at end of file |
