Skip to content

Commit 74892ed

Browse files
authored
controllers/krate/metadata: Read downloads from crate_downloads table (#8253)
1 parent 79701f6 commit 74892ed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/controllers/krate/metadata.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ pub async fn show(app: AppState, Path(name): Path<String>, req: Parts) -> AppRes
3636
.unwrap_or_default();
3737

3838
let conn = &mut *app.db_read()?;
39-
let krate: Crate = Crate::by_name(&name)
39+
let (krate, downloads): (Crate, i64) = Crate::by_name(&name)
40+
.inner_join(crate_downloads::table)
41+
.select((Crate::as_select(), crate_downloads::downloads))
4042
.first(conn)
4143
.optional()?
4244
.ok_or_else(|| crate_not_found(&name))?;
@@ -115,7 +117,7 @@ pub async fn show(app: AppState, Path(name): Path<String>, req: Parts) -> AppRes
115117
cats.as_deref(),
116118
badges,
117119
false,
118-
krate.downloads as i64,
120+
downloads,
119121
recent_downloads,
120122
);
121123
let encodable_versions = versions_publishers_and_audit_actions.map(|vpa| {

0 commit comments

Comments
 (0)