Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds 5-latest-releases-by-author-es.pl
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
scripts/endpoints/release/5-latest-releases-by-author-es.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Data::Printer; | ||
use MetaCPAN::Util qw( es ); | ||
|
||
my $author = shift @ARGV; | ||
die "usage: $0 PAUSEID" if !$author; | ||
|
||
my $latest = es()->search( | ||
index => 'v0', | ||
type => 'release', | ||
fields => [ 'distribution', 'version' ], | ||
size => 500, | ||
query => { | ||
filtered => { | ||
query => { match_all => {} }, | ||
filter => { | ||
and => [ | ||
{ term => { 'release.status' => 'latest' } }, | ||
{ term => { 'release.author' => [$author] }, }, | ||
], | ||
}, | ||
}, | ||
}, | ||
sort => [ { 'release.date' => 'desc' } ], | ||
); | ||
|
||
my @releases = map { $_->{fields} } @{ $latest->{hits}->{hits} }; | ||
p @releases; | ||
|
||
=pod | ||
=head1 DESCRIPTION | ||
This query uses an AND filter to get the latest release by an AUTHOR. Note | ||
that since this is looking for "latest", it will only return releases for which | ||
this author was the last to upload an authorized version. | ||
A release can have one of 3 valid status: latest, cpan or backpan. | ||
=over 4 | ||
=item latest | ||
This is the latest, authorized version of this release. | ||
=item cpan | ||
This release is currently on CPAN. Check the "authorized" field if you want | ||
only authorized releases. | ||
=item backpan | ||
This release is no longer on CPAN and is currently on BackPAN. Check the | ||
"authorized" field if you want only authorized releases. | ||
=back | ||
=cut |