Skip to content
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

Crate with all versions yanked display reduced info #5314

Closed

Conversation

mario-areias
Copy link

@mario-areias mario-areias commented Oct 11, 2022

This PR reduces the information returned by the API when crates have all versions yanked. Specifically badges, documentation, homepage and repository are set to None and max_version is set to "0.0.0". These changes are applied on:

  • GET /crates/:crate_id (crate page)
  • GET /crates (search).

In this PR the definition for a crate with all versions yanked is when crate.versions() returns no results. The versions method loads all non-yanked versions.

This definition simplifies the code a bit, specifically in src/controllers/krate/search.rs since the versions for the queried crates are already loaded in memory, so there is no need to run yet one more query. Semantically though, this definition is not entirely correct. crate.versions() could also mean that all versions have been deleted.

I don't think the difference matters much for this PR, but please do let me know if this is not a valid definition for all versions yanked crates and I will update the PR.

Fix #1058

Search page changes:

image

Crate with 2 yanked versions and 1 non-yanked.

image

Crate with all 3 versions yanked.

Crate page changes:
image
Non-yanked crate.

image

Yanked crate.

@@ -193,7 +205,7 @@ pub fn show(req: &mut dyn RequestExt) -> EndpointResult {
None
};

let badges = if include.badges {
let badges = if include.badges && !all_versions_yanked {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required, but it avoids the database to do run unnecessary queries. It could be premature optimisation, let me know if you would like it removed.

@@ -202,7 +214,7 @@ pub fn show(req: &mut dyn RequestExt) -> EndpointResult {
} else {
None
};
let top_versions = if include.versions {
let top_versions = if include.versions && !all_versions_yanked {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

None,
false,
None,
false,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming there is no way to publish an yanked crate so setting up this to false.

@Turbo87
Copy link
Member

Turbo87 commented Oct 11, 2022

did you check what effects this has on the frontend?

@mario-areias
Copy link
Author

@Turbo87 I did a basic test in my local machine, publishing crates locally. I just added screenshots in the PR description for the changes I can see. I can confirm the API is responding correctly too.

I don't know much about the frontend code though (specifically about badges for example), if you can point me what other tests I should do locally, I will certainly do them.

@Turbo87 Turbo87 added C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works A-backend ⚙️ labels Oct 13, 2022
@bors
Copy link
Contributor

bors commented Nov 6, 2022

☔ The latest upstream changes (presumably 4d4aacc) made this pull request unmergeable. Please resolve the merge conflicts.

@Turbo87
Copy link
Member

Turbo87 commented Nov 16, 2022

FWIW the reason I haven't felt comfortable yet with merging this is that it increases the complexity of the code quite a bit, and in some cases even requires an extra database call.

I'm wondering if it would be better to have a sort of "default version" reference from the crates table to the versions table and store the corresponding data there instead. 🤔

@Turbo87
Copy link
Member

Turbo87 commented May 2, 2023

as mentioned in #1058 (comment), we decided to change course on how we want to deal with and display yanked crates/versions.

sorry for letting this issue be in limbo for so long :-/

@Turbo87 Turbo87 closed this May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crates who have yanked all their versions should only return name, owners, and that it's yanked
3 participants