-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
actually really fix download_url end point for perl releases #1187
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1058,10 +1058,13 @@ sub find_download_url { | |
bool => { | ||
must => [ | ||
{ term => { $prefix . 'authorized' => 1 } }, | ||
{ term => { $prefix . 'indexed' => 1 } }, | ||
( | ||
$module_filter ? { term => { $prefix . 'name' => $name } } | ||
: { term => { 'release' => $name } }, | ||
$module_filter | ||
? ( | ||
{ term => { $prefix . 'indexed' => 1 } }, | ||
{ term => { $prefix . 'name' => $name } } | ||
) | ||
: { term => { 'distribution' => $name } }, | ||
), | ||
( | ||
exists $version_filters->{must} | ||
|
@@ -1143,7 +1146,16 @@ sub find_download_url { | |
query => $query, | ||
size => 1, | ||
sort => \@sort, | ||
_source => [ 'release', 'download_url', 'date', 'status' ], | ||
_source => [ qw( | ||
checksum_md5 | ||
checksum_sha256 | ||
date | ||
download_url | ||
release | ||
status | ||
version | ||
name | ||
) ], | ||
}; | ||
|
||
my $res = $self->es->search( | ||
|
@@ -1158,7 +1170,8 @@ sub find_download_url { | |
my @checksums; | ||
|
||
my $hit = $res->{hits}{hits}[0]; | ||
my $release = exists $hit->{_source} ? $hit->{_source}{release} : undef; | ||
my $source = $hit->{_source}; | ||
my $release = $source->{release}; | ||
|
||
if ($release) { | ||
my $checksums = $self->get_checksums($release); | ||
|
@@ -1176,10 +1189,17 @@ sub find_download_url { | |
); | ||
} | ||
|
||
return +{ | ||
%{ $hit->{_source} }, | ||
%{ $hit->{inner_hits}{module}{hits}{hits}[0]{_source} }, @checksums, | ||
}; | ||
my $source_name = delete $source->{name}; | ||
if ( !$module_filter ) { | ||
$source->{release} = $source_name; | ||
} | ||
|
||
my $module | ||
= $hit->{inner_hits}{module} | ||
? $hit->{inner_hits}{module}{hits}{hits}[0]{_source} | ||
: {}; | ||
|
||
return +{ %$source, %$module, @checksums, }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point, we have verified that there was a result in |
||
} | ||
|
||
sub _version_filters { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably always want to add a
$module //= {}
as we are going to dereference it laterThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ES query that would produce
{inner_hits}{module}
requires a module with a matching name. Ifinner_hits
exists,{inner_hits}{module}{hits}{hits}[0]{_source}
will always exist.