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
5 changes: 4 additions & 1 deletion src/models/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ impl Crate {
}

/// Return both the newest (most recently updated) and
/// highest version (in semver order) for the current crate.
/// highest version (in semver order) for the current crate,
/// where all top versions are not yanked.
pub fn top_versions(&self, conn: &mut impl Conn) -> QueryResult<TopVersions> {
Ok(TopVersions::from_date_version_pairs(
self.versions()
Expand Down Expand Up @@ -475,10 +476,12 @@ impl From<BoxedAppError> for OwnerAddError {
}

pub trait CrateVersions {
/// Return all non-yanked versions of a crate.
fn versions(&self) -> versions::BoxedQuery<'_, Pg> {
self.all_versions().filter(versions::yanked.eq(false))
}

/// Return all versions of a crate, including yanked ones.
fn all_versions(&self) -> versions::BoxedQuery<'_, Pg>;
}

Expand Down
2 changes: 2 additions & 0 deletions src/models/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ fn strip_build_metadata(version: &str) -> &str {

/// The highest version (semver order) and the most recently updated version.
/// Typically used for a single crate.
/// Note: `TopVersion` itself does not guarantee whether versions are yanked or not,
/// this must be guaranteed by the input versions.
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct TopVersions {
/// The "highest" version in terms of semver
Expand Down