Skip to content

Commit 16add2f

Browse files
authored
Merge pull request #39 from metacpan/mickey/cleanup
syntax consistency
2 parents cb29240 + 341b5a5 commit 16add2f

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

bin/backup.pl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,40 +82,37 @@ ()
8282
$bulk_store{$key} ||= $es->bulk( max_count => $batch_size );
8383
my $bulk = $bulk_store{$key};
8484

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

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

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

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

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

9797
# Invalid latitude
98-
delete $raw->{_source}->{location};
98+
delete $raw->{_source}{location};
9999
}
100100
elsif ( $lon > 180 or $lon < -180 ) {
101101

102102
# Invalid longitude
103-
delete $raw->{_source}->{location};
103+
delete $raw->{_source}{location};
104104
}
105105
}
106106
}
107107

108108
if ( $es->exists( id => $raw->{_id} ) ) {
109-
110109
$bulk->update( {
111110
id => $raw->{_id},
112111
doc => $raw->{_source},
113112
doc_as_upsert => 1,
114113
} );
115-
116114
}
117115
else {
118-
119116
$bulk->create( {
120117
id => $raw->{_id},
121118
$parent ? ( parent => $parent ) : (),

bin/check.pl

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,9 @@
8181
[qw< name status authorized version id date >],
8282
query => { match_all => {} },
8383
filter => {
84-
and => [
85-
{
86-
term =>
87-
{ name => $file->{fields}{release} }
88-
}
89-
]
84+
and => [ {
85+
term => { name => $file->{fields}{release} }
86+
} ]
9087
},
9188
);
9289

@@ -108,11 +105,11 @@
108105
log_error {"Could not find latest release for $pkg"};
109106
foreach my $rel (@releases) {
110107
log_warn {" Found release $rel->{fields}{name}"};
111-
log_warn {" STATUS : $rel->{fields}->{status}"};
108+
log_warn {" STATUS : $rel->{fields}{status}"};
112109
log_warn {
113-
" AUTORIZED : $rel->{fields}->{authorized}"
110+
" AUTORIZED : $rel->{fields}{authorized}"
114111
};
115-
log_warn {" DATE : $rel->{fields}->{date}"};
112+
log_warn {" DATE : $rel->{fields}{date}"};
116113
}
117114

118115
$error_count++;
@@ -123,13 +120,13 @@
123120
"Module $pkg doesn't have any releases in ElasticSearch!"
124121
};
125122
foreach my $file (@files) {
126-
log_warn {" Found file $file->{fields}->{name}"};
127-
log_warn {" RELEASE : $file->{fields}->{release}"};
128-
log_warn {" AUTHOR : $file->{fields}->{author}"};
123+
log_warn {" Found file $file->{fields}{name}"};
124+
log_warn {" RELEASE : $file->{fields}{release}"};
125+
log_warn {" AUTHOR : $file->{fields}{author}"};
129126
log_warn {
130-
" AUTHORIZED : $file->{fields}->{authorized}"
127+
" AUTHORIZED : $file->{fields}{authorized}"
131128
};
132-
log_warn {" DATE : $file->{fields}->{date}"};
129+
log_warn {" DATE : $file->{fields}{date}"};
133130
}
134131
$error_count++;
135132
}

bin/latest.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ ()
181181
next
182182
if ( !$force
183183
&& $upgrade{ $file_data->{distribution} }
184-
&& $upgrade{ $file_data->{distribution} }->{release} eq
184+
&& $upgrade{ $file_data->{distribution} }{release} eq
185185
$file_data->{release} );
186186

187187
$to_purge{ $file_data->{download_url} } = 1;

bin/watcher.pl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ()
8282
push( @changes, $_ );
8383
}
8484
if ( !$backpan
85-
&& $json->{meta}->{minmax}->{min} < $latest->date->epoch )
85+
&& $json->{meta}{minmax}{min} < $latest->date->epoch )
8686
{
8787
log_debug {"Includes latest release"};
8888
last;
@@ -185,7 +185,7 @@ ($release)
185185
my $info = CPAN::DistnameInfo->new( $release->{path} );
186186
$release = reindex_release_first($info);
187187
return unless ($release);
188-
log_info {"Moving $release->{_source}->{name} to BackPAN"};
188+
log_info {"Moving $release->{_source}{name} to BackPAN"};
189189

190190
my $scroll_file = $es_file->scroll( {
191191
scroll => '1m',
@@ -199,12 +199,12 @@ ($release)
199199
and => [
200200
{
201201
term => {
202-
release => $release->{_source}->{name}
202+
release => $release->{_source}{name}
203203
}
204204
},
205205
{
206206
term => {
207-
author => $release->{_source}->{author}
207+
author => $release->{_source}{author}
208208
}
209209
},
210210
]
@@ -223,8 +223,8 @@ ($release)
223223
$bulk_file->index( {
224224
id => $row->{_id},
225225
source => {
226-
$row->{fields}->{_parent}
227-
? ( parent => $row->{fields}->{_parent} )
226+
$row->{fields}{_parent}
227+
? ( parent => $row->{fields}{_parent} )
228228
: (),
229229
%$source,
230230
status => 'backpan',

0 commit comments

Comments
 (0)