|
21 | 21 |
|
22 | 22 | # setup |
23 | 23 | my $type2index = { |
24 | | - release => 'cpan', |
25 | | - file => 'cpan', |
26 | | - author => 'cpan', |
27 | | - favorite => 'cpan', |
28 | | - permission => 'cpan', |
29 | | - contributor => 'contributor', |
| 24 | + release => 'cpan', |
| 25 | + file => 'cpan', |
| 26 | + author => 'cpan', |
| 27 | + favorite => 'cpan', |
| 28 | + permission => 'cpan', |
| 29 | + contributor => 'contributor', |
30 | 30 | }; |
31 | 31 |
|
32 | | - |
33 | 32 | purge_author() if $author; |
34 | 33 |
|
35 | 34 | log_info {'Done'}; |
36 | 35 |
|
37 | 36 | sub purge_author () { |
| 37 | + |
38 | 38 | # confirm |
39 | 39 | $release |
40 | | - ? are_you_sure( sprintf("%s's %s release is about to be purged!", $author, $release), $force ) |
41 | | - : are_you_sure( sprintf("All of %s's releases are about to be purged!", $author), $force ); |
| 40 | + ? are_you_sure( |
| 41 | + sprintf( |
| 42 | + "%s's %s release is about to be purged!", $author, $release |
| 43 | + ), |
| 44 | + $force |
| 45 | + ) |
| 46 | + : are_you_sure( |
| 47 | + sprintf( "All of %s's releases are about to be purged!", $author ), |
| 48 | + $force ); |
42 | 49 |
|
43 | 50 | my $query = { |
44 | 51 | bool => { |
45 | 52 | must => [ |
46 | 53 | { term => { author => $author } }, |
47 | | - ( $release |
48 | | - ? { term => { release => $release } } |
49 | | - : () |
| 54 | + ( |
| 55 | + $release |
| 56 | + ? { term => { release => $release } } |
| 57 | + : () |
50 | 58 | ) |
51 | 59 | ] |
52 | 60 | } |
53 | 61 | }; |
54 | 62 |
|
55 | | - purge_ids( type => 'favorite', query => $query); |
56 | | - purge_ids( type => 'file', query => $query); |
57 | | - purge_ids( type => 'release', query => $query); |
| 63 | + purge_ids( type => 'favorite', query => $query ); |
| 64 | + purge_ids( type => 'file', query => $query ); |
| 65 | + purge_ids( type => 'release', query => $query ); |
58 | 66 | if ( !$release ) { |
59 | | - purge_ids( type => 'author', id => $author ); |
| 67 | + purge_ids( type => 'author', id => $author ); |
60 | 68 | purge_ids( type => 'contributor', id => $author ); |
61 | 69 | } |
62 | 70 | } |
63 | 71 |
|
64 | | -sub purge_ids ( %args ) { |
| 72 | +sub purge_ids (%args) { |
65 | 73 | my $type = $args{type}; |
66 | | - my $es = MetaCPAN::ES->new( |
| 74 | + my $es = MetaCPAN::ES->new( |
67 | 75 | index => $type2index->{$type}, |
68 | | - type => $type |
| 76 | + type => $type |
69 | 77 | ); |
70 | 78 |
|
71 | 79 | my $bulk = $es->bulk; |
72 | 80 |
|
73 | 81 | my $id = $args{id}; |
74 | | - my $ids = $id |
75 | | - ? [ $id ] |
| 82 | + my $ids |
| 83 | + = $id |
| 84 | + ? [$id] |
76 | 85 | : $es->get_ids( query => $args{query} ); |
77 | 86 |
|
78 | 87 | $bulk->delete_ids(@$ids); |
|
0 commit comments