Skip to content

Commit b186254

Browse files
committed
views/EncodableCrate: Add downloads argument to from() fn
1 parent 4a29008 commit b186254

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/controllers/krate/metadata.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ pub async fn show(app: AppState, Path(name): Path<String>, req: Parts) -> AppRes
115115
cats.as_deref(),
116116
badges,
117117
false,
118+
krate.downloads as i64,
118119
recent_downloads,
119120
);
120121
let encodable_versions = versions_publishers_and_audit_actions.map(|vpa| {

src/views.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,13 @@ impl EncodableCrate {
230230
categories: Option<&[Category]>,
231231
badges: Option<Vec<()>>,
232232
exact_match: bool,
233+
downloads: i64,
233234
recent_downloads: Option<i64>,
234235
) -> Self {
235236
let Crate {
236237
name,
237238
created_at,
238239
updated_at,
239-
downloads,
240240
description,
241241
homepage,
242242
documentation,
@@ -272,7 +272,6 @@ impl EncodableCrate {
272272
// behind the number of "recent downloads". to hide this inconsistency
273273
// we will use the "recent downloads" as "total downloads" in case it is
274274
// higher.
275-
let downloads = downloads as i64;
276275
let downloads = if matches!(recent_downloads, Some(x) if x > downloads) {
277276
recent_downloads.unwrap()
278277
} else {
@@ -316,6 +315,7 @@ impl EncodableCrate {
316315
exact_match: bool,
317316
recent_downloads: Option<i64>,
318317
) -> Self {
318+
let downloads = krate.downloads as i64;
319319
Self::from(
320320
krate,
321321
top_versions,
@@ -324,6 +324,7 @@ impl EncodableCrate {
324324
None,
325325
badges,
326326
exact_match,
327+
downloads,
327328
recent_downloads,
328329
)
329330
}

0 commit comments

Comments
 (0)