-
Notifications
You must be signed in to change notification settings - Fork 212
Show at most one crate from the same repo in /releases search #1375
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the statement gives us the results we want we should check the EXPLAIN
output with a production-sized DB to be sure if it's fast enough.
There are several other ways do the query, we can try these if the PARTITION
happens to be too slow.
src/db/migrate.rs
Outdated
@@ -736,6 +736,11 @@ pub fn migrate(version: Option<Version>, conn: &mut Client) -> crate::error::Res | |||
"ALTER TABLE builds RENAME COLUMN cratesfyi_version TO docsrs_version", | |||
"ALTER TABLE builds RENAME COLUMN docsrs_version TO cratesfyi_version", | |||
), | |||
migration!( | |||
context, 30, "Ensure repos don't have multiple ids", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context, 30, "Ensure repos don't have multiple ids", | |
context, 30, "Ensure repos don't have multiple names", |
releases.release_time, | ||
releases.rustdoc_status, | ||
repositories.stars, | ||
rank() OVER (PARTITION BY repository_id ORDER BY release_time DESC) AS rank |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will filter all releases without repository (where releases.repository_id
is NULL
) except the most recent one.
((NOT $3) OR (releases.build_status = FALSE AND releases.is_library = TRUE)) | ||
AND {0} IS NOT NULL | ||
) i | ||
WHERE rank = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHERE rank = 1 | |
WHERE i.repository_id IS NULL OR rank = 1 |
other thought, only to be safe: It was an intended change that this grouping will happen for all release lists? |
Before, it would create two different repos with the same name, which messed up searching.
This avoids showing rustc_ap_* three dozen times in a row. TODO: is it correct to pick the latest published crate? Is there a way to find the "main" crate from a repository?
I reverted the unique constraint after the discussion we had on discord:
|
Sure, seems reasonable. I won't have time to work on this any time soon anyway. |
This avoids showing rustc_ap_* three dozen times in a row.
TODO: is it correct to pick the latest published crate? Is there a way
to find the "main" crate from a repository?
The first commit caught several bugs and should go in separately even if this doesn't land.
Fixes #985.