Skip to content

Commit ffff496

Browse files
committed
controllers/version: Avoid loading entire Crate within the load_version() fn
1 parent edb9362 commit ffff496

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/controllers/version.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ pub struct CrateVersionPath {
3131

3232
impl CrateVersionPath {
3333
pub async fn load_version(&self, conn: &mut AsyncPgConnection) -> AppResult<Version> {
34-
Ok(self.load_version_and_crate(conn).await?.0)
34+
use ext::*;
35+
36+
let (_, version) = self
37+
.crate_and_version()
38+
.select((crates::id, Option::<Version>::as_select()))
39+
.first::<(i32, _)>(conn)
40+
.await
41+
.optional()?
42+
.gather_from_path(self)?;
43+
Ok(version)
3544
}
3645

3746
pub async fn load_version_and_crate(

0 commit comments

Comments
 (0)