- Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcompare-v0-v1-status-numbers-files-releases.pl
51 lines (41 loc) · 1.38 KB
/
compare-v0-v1-status-numbers-files-releases.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use strict;
use warnings;
use Term::ANSIColor;
use MetaCPAN::Client;
my%domain = (
V0=>'api.metacpan.org',
V1=>'fastapi.metacpan.org',
);
my%results;
formy$ver ( qw< V0 V1 > ) {
my$mcpan = MetaCPAN::Client->new( domain=>$domain{$ver}, version=>lc($ver) );
formy$type ( qw< files releases > ) {
my$scroller = $mcpan->all( $type, get_filter_facets($ver) );
$results{$type}{$ver} = (
$vereq'V0'
? +{ map { $_->{term} =>$_->{count} } @{ $scroller->facets->{count}{terms} } }
: +{ map { $_->{key} =>$_->{doc_count} } @{ $scroller->aggregations->{count}{buckets} } }
);
}
}
my$line = "%-20s %-20s %-20s\n";
printf$line, map { yellow($_) } '', qw< V0 V1 >;
formy$type ( qw< files releases > ) {
print green(uc($type)), "\n";
formy$key ( qw< backpan cpan latest > ) {
printf$line, white($key), map { blue( $results{$type}{$_}{$key} ) } qw< V0 V1 >;
}
print"\n";
}
1;
#################
subyellow { colored($_[0], "bold yellow" ) }
subwhite { colored($_[0], "bold white" ) }
subblue { colored($_[0], "bold bright_blue" ) }
subgreen { colored($_[0], "bold underline green" ) }
subget_filter_facets {
my$ver = shift;
my$key = $vereq'V0' ? 'facets' : 'aggregations';
return +{ $key=> { count=> { terms=> { field=>"status" } } } };
}
1;