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 @@ -72,8 +72,13 @@ pub fn summary(req: &mut dyn RequestExt) -> EndpointResult {
7272 . select ( selection)
7373 . limit ( 10 )
7474 . load ( & * conn) ?;
75- let most_downloaded = crates
76- . left_join ( recent_crate_downloads:: table)
75+
76+ let mut most_downloaded_query = crates. left_join ( recent_crate_downloads:: table) . into_boxed ( ) ;
77+ if !config. excluded_crate_names . is_empty ( ) {
78+ most_downloaded_query =
79+ most_downloaded_query. filter ( name. ne ( all ( & config. excluded_crate_names ) ) ) ;
80+ }
81+ let most_downloaded = most_downloaded_query
7782 . then_order_by ( downloads. desc ( ) )
7883 . select ( selection)
7984 . 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