diff --git a/bin/backup.pl b/bin/backup.pl index a437282..5ec8c8c 100644 --- a/bin/backup.pl +++ b/bin/backup.pl @@ -82,12 +82,12 @@ () $bulk_store{$key} ||= $es->bulk( max_count => $batch_size ); my $bulk = $bulk_store{$key}; - my $parent = $raw->{fields}->{_parent}; + my $parent = $raw->{fields}{_parent}; if ( $raw->{_type} eq 'author' ) { # Hack for dodgy lat / lon's - if ( my $loc = $raw->{_source}->{location} ) { + if ( my $loc = $raw->{_source}{location} ) { my $lat = $loc->[1]; my $lon = $loc->[0]; @@ -95,27 +95,24 @@ () if ( $lat > 90 or $lat < -90 ) { # Invalid latitude - delete $raw->{_source}->{location}; + delete $raw->{_source}{location}; } elsif ( $lon > 180 or $lon < -180 ) { # Invalid longitude - delete $raw->{_source}->{location}; + delete $raw->{_source}{location}; } } } if ( $es->exists( id => $raw->{_id} ) ) { - $bulk->update( { id => $raw->{_id}, doc => $raw->{_source}, doc_as_upsert => 1, } ); - } else { - $bulk->create( { id => $raw->{_id}, $parent ? ( parent => $parent ) : (), diff --git a/bin/check.pl b/bin/check.pl index 2b932b5..2e4fb82 100644 --- a/bin/check.pl +++ b/bin/check.pl @@ -81,12 +81,9 @@ [qw< name status authorized version id date >], query => { match_all => {} }, filter => { - and => [ - { - term => - { name => $file->{fields}{release} } - } - ] + and => [ { + term => { name => $file->{fields}{release} } + } ] }, ); @@ -108,11 +105,11 @@ log_error {"Could not find latest release for $pkg"}; foreach my $rel (@releases) { log_warn {" Found release $rel->{fields}{name}"}; - log_warn {" STATUS : $rel->{fields}->{status}"}; + log_warn {" STATUS : $rel->{fields}{status}"}; log_warn { - " AUTORIZED : $rel->{fields}->{authorized}" + " AUTORIZED : $rel->{fields}{authorized}" }; - log_warn {" DATE : $rel->{fields}->{date}"}; + log_warn {" DATE : $rel->{fields}{date}"}; } $error_count++; @@ -123,13 +120,13 @@ "Module $pkg doesn't have any releases in ElasticSearch!" }; foreach my $file (@files) { - log_warn {" Found file $file->{fields}->{name}"}; - log_warn {" RELEASE : $file->{fields}->{release}"}; - log_warn {" AUTHOR : $file->{fields}->{author}"}; + log_warn {" Found file $file->{fields}{name}"}; + log_warn {" RELEASE : $file->{fields}{release}"}; + log_warn {" AUTHOR : $file->{fields}{author}"}; log_warn { - " AUTHORIZED : $file->{fields}->{authorized}" + " AUTHORIZED : $file->{fields}{authorized}" }; - log_warn {" DATE : $file->{fields}->{date}"}; + log_warn {" DATE : $file->{fields}{date}"}; } $error_count++; } diff --git a/bin/latest.pl b/bin/latest.pl index c437de3..a3e98dd 100644 --- a/bin/latest.pl +++ b/bin/latest.pl @@ -181,7 +181,7 @@ () next if ( !$force && $upgrade{ $file_data->{distribution} } - && $upgrade{ $file_data->{distribution} }->{release} eq + && $upgrade{ $file_data->{distribution} }{release} eq $file_data->{release} ); $to_purge{ $file_data->{download_url} } = 1; diff --git a/bin/watcher.pl b/bin/watcher.pl index 16fb0b1..78fa1d4 100644 --- a/bin/watcher.pl +++ b/bin/watcher.pl @@ -82,7 +82,7 @@ () push( @changes, $_ ); } if ( !$backpan - && $json->{meta}->{minmax}->{min} < $latest->date->epoch ) + && $json->{meta}{minmax}{min} < $latest->date->epoch ) { log_debug {"Includes latest release"}; last; @@ -185,7 +185,7 @@ ($release) my $info = CPAN::DistnameInfo->new( $release->{path} ); $release = reindex_release_first($info); return unless ($release); - log_info {"Moving $release->{_source}->{name} to BackPAN"}; + log_info {"Moving $release->{_source}{name} to BackPAN"}; my $scroll_file = $es_file->scroll( { scroll => '1m', @@ -199,12 +199,12 @@ ($release) and => [ { term => { - release => $release->{_source}->{name} + release => $release->{_source}{name} } }, { term => { - author => $release->{_source}->{author} + author => $release->{_source}{author} } }, ] @@ -223,8 +223,8 @@ ($release) $bulk_file->index( { id => $row->{_id}, source => { - $row->{fields}->{_parent} - ? ( parent => $row->{fields}->{_parent} ) + $row->{fields}{_parent} + ? ( parent => $row->{fields}{_parent} ) : (), %$source, status => 'backpan',