Skip to content

Commit

Permalink
Merge pull request #459 from CPAN-API/leo/cleanup_auth_data
Browse files Browse the repository at this point in the history
strip out invalid lat/lon values
  • Loading branch information
oalders committed Apr 22, 2016
2 parents f95d58c + 43551cf commit 618607e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/MetaCPAN/Script/Backup.pm
Expand Up @@ -131,6 +131,27 @@ sub run_restore {

my $parent = $raw->{fields}->{_parent};

if ( $raw->{_type} eq 'author' ) {

# Hack for dodgy lat / lon's
if ( my $loc = $raw->{_source}->{location} ) {

my $lat = $loc->[1];
my $lon = $loc->[0];

if ( $lat > 90 or $lat < -90 ) {

# Invalid latitude
delete $raw->{_source}->{location};
}
elsif ( $lon > 180 or $lon < -180 ) {

# Invalid longitude
delete $raw->{_source}->{location};
}
}
}

$bulk->create(
{
id => $raw->{_id},
Expand Down

0 comments on commit 618607e

Please sign in to comment.