File tree Expand file tree Collapse file tree 2 files changed +12
-35
lines changed Expand file tree Collapse file tree 2 files changed +12
-35
lines changed Original file line number Diff line number Diff line change @@ -25,22 +25,24 @@ sub all : Local : Args(0) {
2525sub topuploaders : Private {
2626 my ( $self , $c , $range ) = @_ ;
2727
28- my $data = $c -> model(' API::Release' )-> topuploaders($range )-> recv ;
29- my $counts = { map { $_ -> {key } => $_ -> {doc_count } }
30- @{ $data -> {aggregations }{author }{entries }{buckets } } };
31- my $authors = $c -> model(' API::Author' )-> get( keys %$counts )-> recv ;
28+ my $data = $c -> model(' API::Release' )-> topuploaders($range );
29+
30+ my $authors
31+ = $c -> model(' API::Author' )-> get( keys %{ $data -> {counts } } )-> recv ;
32+
3233 $c -> stash(
3334 {
3435 authors => [
3536 sort { $b -> {releases } <=> $a -> {releases } } map {
3637 {
3738 %{ $_ -> {_source } },
38- releases => $counts -> { $_ -> {_source }-> {pauseid } }
39+ releases =>
40+ $data -> {counts }{ $_ -> {_source }-> {pauseid } }
3941 }
4042 } @{ $authors -> {hits }{hits } }
4143 ],
4244 took => $data -> {took },
43- total => $data -> {aggregations }{ author }{ total },
45+ total => $data -> {total },
4446 template => ' recent/topuploaders.html' ,
4547 range => $range ,
4648 }
Original file line number Diff line number Diff line change @@ -352,35 +352,10 @@ sub favorites {
352352
353353sub topuploaders {
354354 my ( $self , $range ) = @_ ;
355- my $range_filter = {
356- range => {
357- date => {
358- from => $range eq ' all' ? 0 : DateTime-> now-> subtract(
359- $range eq ' weekly' ? ' weeks'
360- : $range eq ' monthly' ? ' months'
361- : $range eq ' yearly' ? ' years'
362- : ' weeks' => 1
363- )-> truncate ( to => ' day' )-> iso8601
364- },
365- }
366- };
367- $self -> request(
368- ' /release/_search' ,
369- {
370- query => { match_all => {} },
371- aggregations => {
372- author => {
373- aggregations => {
374- entries => {
375- terms => { field => ' author' , size => 50 }
376- }
377- },
378- filter => $range_filter ,
379- },
380- },
381- size => 0,
382- }
383- );
355+ my $param = $range ? { range => $range } : ();
356+ my $data
357+ = $self -> request( ' /release/top_uploaders' , undef , $param )-> recv ;
358+ return $data ;
384359}
385360
386361sub no_latest {
You can’t perform that action at this time.
0 commit comments