File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -73,8 +73,13 @@ pub fn summary(req: &mut dyn RequestExt) -> EndpointResult {
7373 . select ( selection)
7474 . limit ( 10 )
7575 . load ( & * conn) ?;
76- let most_downloaded = crates
77- . left_join ( recent_crate_downloads:: table)
76+
77+ let mut most_downloaded_query = crates. left_join ( recent_crate_downloads:: table) . into_boxed ( ) ;
78+ if !config. excluded_crate_names . is_empty ( ) {
79+ most_downloaded_query =
80+ most_downloaded_query. filter ( name. ne ( all ( & config. excluded_crate_names ) ) ) ;
81+ }
82+ let most_downloaded = most_downloaded_query
7883 . then_order_by ( downloads. desc ( ) )
7984 . select ( selection)
8085 . limit ( 10 )
Original file line number Diff line number Diff line change @@ -142,6 +142,10 @@ fn excluded_crate_id() {
142142
143143 let json: SummaryResponse = anon. get ( "/api/v1/summary" ) . good ( ) ;
144144
145+ assert_eq ! ( json. most_downloaded. len( ) , 1 ) ;
146+ assert_eq ! ( json. most_downloaded[ 0 ] . name, "some_downloads" ) ;
147+ assert_eq ! ( json. most_downloaded[ 0 ] . downloads, 20 ) ;
148+
145149 assert_eq ! ( json. most_recently_downloaded. len( ) , 1 ) ;
146150 assert_eq ! ( json. most_recently_downloaded[ 0 ] . name, "some_downloads" ) ;
147151 assert_eq ! ( json. most_recently_downloaded[ 0 ] . recent_downloads, Some ( 10 ) ) ;
You can’t perform that action at this time.
0 commit comments