Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bin/crates-admin/yank_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async fn yank(opts: Opts, conn: &mut AsyncPgConnection) -> anyhow::Result<()> {

let v: Version = Version::belonging_to(&krate)
.filter(versions::num.eq(&version))
.select(Version::as_select())
.first(conn)
.await?;

Expand Down
1 change: 1 addition & 0 deletions src/controllers/krate/downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub async fn downloads(state: AppState, Path(crate_name): Path<String>) -> AppRe

let mut versions: Vec<Version> = versions::table
.filter(versions::crate_id.eq(crate_id))
.select(Version::as_select())
.load(&mut conn)
.await?;

Expand Down
1 change: 1 addition & 0 deletions src/controllers/krate/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ pub async fn search(app: AppState, req: Parts) -> AppResult<ErasedJson> {
let span = info_span!("db.query", message = "SELECT ... FROM versions");
let versions: Vec<Version> = Version::belonging_to(&crates)
.filter(versions::yanked.eq(false))
.select(Version::as_select())
.load(&mut conn)
.instrument(span)
.await?;
Expand Down
1 change: 1 addition & 0 deletions src/controllers/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub async fn summary(state: AppState) -> AppResult<ErasedJson> {
let krates = data.iter().map(|(c, ..)| c).collect::<Vec<_>>();
let versions: Vec<Version> = Version::belonging_to(&krates)
.filter(versions::yanked.eq(false))
.select(Version::as_select())
.load(conn)
.await?;

Expand Down
5 changes: 4 additions & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ pub async fn index_metadata(
krate: &Crate,
conn: &mut AsyncPgConnection,
) -> QueryResult<Vec<crates_io_index::Crate>> {
let mut versions: Vec<Version> = Version::belonging_to(krate).load(conn).await?;
let mut versions: Vec<Version> = Version::belonging_to(krate)
.select(Version::as_select())
.load(conn)
.await?;

// We sort by `created_at` by default, but since tests run within a
// single database transaction the versions will all have the same
Expand Down
1 change: 1 addition & 0 deletions src/models/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ impl Crate {
) -> AppResult<Version> {
Version::belonging_to(self)
.filter(versions::num.eq(version))
.select(Version::as_select())
.first(conn)
.await
.optional()?
Expand Down
2 changes: 1 addition & 1 deletion src/models/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub struct Version {
pub has_lib: Option<bool>,
pub bin_names: Option<Vec<Option<String>>>,
pub yank_message: Option<String>,
pub num_no_build: String,
pub edition: Option<String>,
pub description: Option<String>,
pub homepage: Option<String>,
Expand Down Expand Up @@ -117,6 +116,7 @@ impl NewVersion<'_> {
async move {
let version: Version = insert_into(versions::table)
.values(self)
.returning(Version::as_returning())
.get_result(conn)
.await?;

Expand Down
3 changes: 3 additions & 0 deletions src/worker/jobs/downloads/update_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ mod tests {

let version_before: Version = versions::table
.find(version.id)
.select(Version::as_select())
.first(&mut conn)
.await
.unwrap();
Expand All @@ -299,6 +300,7 @@ mod tests {

let version2: Version = versions::table
.find(version.id)
.select(Version::as_select())
.first(&mut conn)
.await
.unwrap();
Expand All @@ -324,6 +326,7 @@ mod tests {

let version3: Version = versions::table
.find(version.id)
.select(Version::as_select())
.first(&mut conn)
.await
.unwrap();
Expand Down