File: es_filter.pl

package info (click to toggle)
libmetacpan-client-perl 2.029000-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 548 kB
  • sloc: perl: 2,540; makefile: 8
file content (27 lines) | stat: -rw-r--r-- 715 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;

use MetaCPAN::Client;

# use raw ES filter on a { match_all => {} } query

# find 'latest' status releases with at least 700 failing tests
# which consist at least 50% of their overall number of tests.

my $release = MetaCPAN::Client->new->all(
    'releases',
    {
        es_filter => {
            and => [
                { range => { 'tests.fail' => { gte => 700 } } },
                { term  => { 'status' => 'latest' } }
            ]
        },
    }
);

while ( my $r = $release->next ) {
    my $fail = $r->tests->{fail};
    my $all  = 0; $all += $_ for @{ $r->tests }{qw/pass fail na unknown/};
    ($fail / $all) >= 0.5 and printf "%4d/%4d: %s\n", $fail, $all, $r->name;
}