Skip to content

Commit 8c3dd17

Browse files
committed
Exclude crates from all time downloaded list too
1 parent 0b39c70 commit 8c3dd17

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/controllers/krate/metadata.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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)

src/tests/krate/summary.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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));

0 commit comments

Comments
 (0)