@@ -135,7 +135,8 @@ sub search_distribution {
135135 my @ids = map { $_ -> {fields }-> {id } } @{ $data -> {hits }-> {hits } };
136136 my $descriptions = $self -> search_descriptions(@ids );
137137 my $ratings = $self -> model(' Rating' )-> get(@distributions );
138- my $favorites = $self -> model(' Favorite' )-> get($user , @distributions );
138+ my $favorites
139+ = $self -> model(' Favorite' )-> get( $user , @distributions );
139140 return $ratings & $favorites & $descriptions ;
140141 }
141142 )-> (
@@ -190,8 +191,9 @@ sub search_collapsed {
190191 }
191192
192193 @distributions = splice ( @distributions , $from , 20 );
193- my $ratings = $self -> model(' Rating' )-> get(@distributions );
194- my $favorites = $self -> model(' Favorite' )-> get($user , @distributions );
194+ my $ratings = $self -> model(' Rating' )-> get(@distributions );
195+ my $favorites
196+ = $self -> model(' Favorite' )-> get( $user , @distributions );
195197 my $results
196198 = $self -> model(' Module' )
197199 -> search( $query ,
@@ -461,6 +463,43 @@ sub _search_in_distributions {
461463 }
462464 } };
463465}
464- __PACKAGE__ -> meta-> make_immutable;
465466
466- 1;
467+ sub requires {
468+ my ( $self , $module , $page ) = @_ ;
469+ my $cv = $self -> cv;
470+ $self -> request(
471+ ' /release/_search' ,
472+ { query => {
473+ filtered => {
474+ query => { " match_all" => {} },
475+ filter => {
476+ and => [
477+ { term => { ' release.status' => ' latest' } },
478+ { term => { ' release.authorized' => \1 } },
479+ { term => {
480+ " release.dependency.module" => $module
481+ }
482+ }
483+ ]
484+ }
485+ }
486+ },
487+ size => 50,
488+ from => $page * 50 - 50,
489+ sort => [{date => ' desc' }],
490+ }
491+ )-> (
492+ sub {
493+ my $data = shift -> recv ;
494+ $cv -> send (
495+ { data => [map { $_ -> {_source } } @{$data -> {hits }-> {hits }}],
496+ total => $data -> {hits }-> {total },
497+ took => $data -> {took }
498+ }
499+ );
500+ }
501+ );
502+ return $cv ;
503+ }
504+
505+ __PACKAGE__ -> meta-> make_immutable;
0 commit comments