Skip to content

Commit

Permalink
Merge pull request #39 from metacpan/mickey/cleanup
Browse files Browse the repository at this point in the history
syntax consistency
  • Loading branch information
mickeyn authored Sep 30, 2024
2 parents cb29240 + 341b5a5 commit 16add2f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
11 changes: 4 additions & 7 deletions bin/backup.pl
Original file line number Diff line number Diff line change
Expand Up @@ -82,40 +82,37 @@ ()
$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];

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 ) : (),
Expand Down
25 changes: 11 additions & 14 deletions bin/check.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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} }
} ]
},
);

Expand All @@ -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++;
Expand All @@ -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++;
}
Expand Down
2 changes: 1 addition & 1 deletion bin/latest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions bin/watcher.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand All @@ -199,12 +199,12 @@ ($release)
and => [
{
term => {
release => $release->{_source}->{name}
release => $release->{_source}{name}
}
},
{
term => {
author => $release->{_source}->{author}
author => $release->{_source}{author}
}
},
]
Expand All @@ -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',
Expand Down

0 comments on commit 16add2f

Please sign in to comment.