Skip to content

Commit fd1856a

Browse files
committed
database/models/download: Implement Selectable trait
1 parent b5b2382 commit fd1856a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

crates/crates_io_database/src/models/download.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ use chrono::NaiveDate;
44
use crates_io_diesel_helpers::SemverVersion;
55
use diesel::prelude::*;
66

7-
#[derive(Queryable, Identifiable, Associations, Debug, Clone, Copy)]
7+
#[derive(Queryable, Identifiable, Selectable, Associations, Debug, Clone, Copy)]
88
#[diesel(
99
primary_key(version_id, date),
1010
belongs_to(FullVersion, foreign_key=version_id),
1111
belongs_to(Version),
1212
)]
1313
pub struct VersionDownload {
1414
pub version_id: i32,
15-
pub downloads: i32,
16-
pub counted: i32,
1715
pub date: NaiveDate,
18-
pub processed: bool,
16+
pub downloads: i32,
1917
}
2018

2119
/// A subset of the columns of the `versions` table.

src/controllers/krate/downloads.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ pub async fn get_crate_downloads(
111111
let (downloads, extra_downloads, versions_and_publishers, actions) = tokio::try_join!(
112112
VersionDownload::belonging_to(latest_five)
113113
.filter(version_downloads::date.gt(date(now - 90.days())))
114+
.select(VersionDownload::as_select())
114115
.order((
115116
version_downloads::date.asc(),
116117
version_downloads::version_id.desc(),

src/controllers/version/downloads.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ pub async fn get_version_downloads(
9393

9494
let version_downloads = VersionDownload::belonging_to(&version)
9595
.filter(version_downloads::date.between(cutoff_start_date, cutoff_end_date))
96+
.select(VersionDownload::as_select())
9697
.order(version_downloads::date)
9798
.load(&mut conn)
9899
.await?

0 commit comments

Comments
 (0)