Skip to content

Commit 46c4630

Browse files
committed
purge - fix script
1 parent fbfd09e commit 46c4630

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

bin/purge.pl

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,14 @@
1212
>;
1313

1414
# args
15-
my ( $author, $release, $force );
15+
my ( $author, $force, $release );
1616
GetOptions(
1717
"author=s" => \$author,
18-
"release=s" => \$release,
1918
"force" => \$force,
19+
"release=s" => \$release,
2020
);
2121

2222
# setup
23-
my $type2index = {
24-
release => 'cpan',
25-
file => 'cpan',
26-
author => 'cpan',
27-
favorite => 'cpan',
28-
permission => 'cpan',
29-
contributor => 'contributor',
30-
};
31-
3223
purge_author() if $author;
3324

3425
log_info {'Done'};
@@ -60,22 +51,17 @@ ()
6051
}
6152
};
6253

63-
purge_ids( type => 'favorite', query => $query );
64-
purge_ids( type => 'file', query => $query );
65-
purge_ids( type => 'release', query => $query );
54+
purge_ids( index => 'favorite', query => $query );
55+
purge_ids( index => 'file', query => $query );
56+
purge_ids( index => 'release', query => $query );
6657
if ( !$release ) {
67-
purge_ids( type => 'author', id => $author );
68-
purge_ids( type => 'contributor', id => $author );
58+
purge_ids( index => 'author', id => $author );
59+
purge_ids( index => 'contributor', id => $author );
6960
}
7061
}
7162

7263
sub purge_ids (%args) {
73-
my $type = $args{type};
74-
my $es = MetaCPAN::ES->new(
75-
index => $type2index->{$type},
76-
type => $type
77-
);
78-
64+
my $es = MetaCPAN::ES->new( index => $args{index} );
7965
my $bulk = $es->bulk;
8066

8167
my $id = $args{id};

0 commit comments

Comments
 (0)