Skip to content

Show at most one release per crate on /releases #989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2020
Merged
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
11 changes: 9 additions & 2 deletions src/web/releases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ pub(crate) fn get_releases(conn: &mut Client, page: i64, limit: i64, order: Orde
crates.github_stars
FROM crates
INNER JOIN releases ON crates.id = releases.crate_id
WHERE (NOT $3) OR (releases.build_status = FALSE AND releases.is_library = TRUE)
WHERE
((NOT $3) OR (releases.build_status = FALSE AND releases.is_library = TRUE))
AND crates.latest_version_id = releases.id
ORDER BY {} DESC
LIMIT $1 OFFSET $2",
ordering,
Expand Down Expand Up @@ -1024,6 +1026,11 @@ mod tests {
.name("crate_that_succeeded")
.version("0.1.0")
.create()?;
// make sure that crates get at most one release shown, so they don't crowd the page
env.fake_release()
.name("crate_that_succeeded")
.version("0.2.0")
.create()?;
env.fake_release()
.name("crate_that_failed")
.version("0.1.0")
Expand All @@ -1046,7 +1053,7 @@ mod tests {
let url = attributes.get("href").unwrap();
if url.contains("crate_that_succeeded") {
assert_eq!(
url, "/crate_that_succeeded/0.1.0/crate_that_succeeded",
url, "/crate_that_succeeded/0.2.0/crate_that_succeeded",
"for path {}",
path
);
Expand Down