Skip to content

Commit 4a8ecea

Browse files
committed
controllers/version: Add the CrateVersionPathExt trait and provide crate_and_version() fn
Since most endpoints don't need all of the columns for `crates` and `versions`, it would be great to only load the columns we actually need to make things faster. This will enable other endpoints to use the function to make a base query and customize the needed columns.
1 parent 58f9030 commit 4a8ecea

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/controllers/version.rs

+10
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,14 @@ mod ext {
8080
)
8181
.filter(canon_crate_name(crates::name).eq(canon_crate_name(crate_name)))
8282
}
83+
84+
pub trait CrateVersionPathExt {
85+
fn crate_and_version(&self) -> crate_and_version_query<'_>;
86+
}
87+
88+
impl CrateVersionPathExt for CrateVersionPath {
89+
fn crate_and_version(&self) -> crate_and_version_query<'_> {
90+
crate_and_version_query(&self.name, &self.version)
91+
}
92+
}
8393
}

0 commit comments

Comments
 (0)