Skip to content

Yanked crates shouldn't be displayed on user/team pages #958

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

Closed
2 tasks
carols10cents opened this issue Aug 13, 2017 · 7 comments · Fixed by #1642
Closed
2 tasks

Yanked crates shouldn't be displayed on user/team pages #958

carols10cents opened this issue Aug 13, 2017 · 7 comments · Fixed by #1642
Labels
C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works E-has-mentor

Comments

@carols10cents
Copy link
Member

carols10cents commented Aug 13, 2017

Related to #145.

Since we currently only keep track of yanked-ness on version records rather than on crate records, implementing this involves:

  • Changing the query for the crates a user owns and the query for the crates a team owns to have an additional condition that there must be at least one version associated with that crate that has yanked equal to false.
    • I expect figuring out the diesel incantation to express this condition to be the most difficult part of this issue; give it a try and post what you've tried and I can help figure it out if you get stuck!
  • Make a new test similar to this one that if the user or team in the test owns a crate where all versions have been yanked, that crate does NOT show up in the JSON response.
@carols10cents carols10cents added A-yank C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works labels Aug 13, 2017
mauricio pushed a commit to mauricio/crates.io that referenced this issue Aug 20, 2017
…ersion

This makes the index call only show crates that have at least
one available version. Crates that have all versions yanked
will not show up anymore.

Fixes rust-lang#958
mauricio pushed a commit to mauricio/crates.io that referenced this issue Aug 20, 2017
…ersion

This makes the index call only show crates that have at least
one available version. Crates that have all versions yanked
will not show up anymore.

Fixes rust-lang#958
mauricio pushed a commit to mauricio/crates.io that referenced this issue Aug 25, 2017
…ersion

This makes the index call only show crates that have at least
one available version. Crates that have all versions yanked
will not show up anymore.

Fixes rust-lang#958
mauricio pushed a commit to mauricio/crates.io that referenced this issue Aug 25, 2017
…ersion

This makes the index call only show crates that have at least
one available version. Crates that have all versions yanked
will not show up anymore.

Fixes rust-lang#958
mauricio pushed a commit to mauricio/crates.io that referenced this issue Aug 25, 2017
…ersion

This makes the index call only show crates that have at least
one available version. Crates that have all versions yanked
will not show up anymore.

Fixes rust-lang#958
@sodiumjoe
Copy link

I'd like to give this a shot.

@sgrif
Copy link
Contributor

sgrif commented Dec 13, 2017

Is there ever a case where we want the /crates route to include yanked crates? If not something like this should do it:

diff --git a/src/krate/search.rs b/src/krate/search.rs
index 3a8030a..dfa59d0 100644
--- a/src/krate/search.rs
+++ b/src/krate/search.rs
@@ -50,6 +50,11 @@ pub fn search(req: &mut Request) -> CargoResult<Response> {
     let recent_downloads = sql::<Nullable<BigInt>>("SUM(crate_downloads.downloads)");
 
     let mut query = crates::table
+        .filter(exists(
+            versions::table
+                .filter(versions::crate_id.eq(crates::id))
+                .filter(versions::yanked.eq(false)),
+        ))
         .left_join(
             crate_downloads::table.on(
                 crates::id

@carols10cents
Copy link
Member Author

Is there ever a case where we want the /crates route to include yanked crates?

Yes. When you're searching to see if a name is taken, we should show yanked crates because that name can't be used.

#1058
#145

@sgrif
Copy link
Contributor

sgrif commented Dec 13, 2017

Gotcha. In that case, the patch I pasted above should still work, but placed in the conditionals where we want it, rather than the line I have it on.

@sgrif
Copy link
Contributor

sgrif commented Dec 13, 2017

Alternatively, that filter can become exists(...).or(exact_match)

@sgrif
Copy link
Contributor

sgrif commented Dec 13, 2017

I've opened diesel-rs/diesel#1389 which might make that a bit easier as well (this PR shouldn't be blocked on that though)

@bryanburgers
Copy link
Contributor

bryanburgers commented Feb 27, 2019

Should we use something like /api/v1/crates?include_yanked=n?

I took a shot at this using

query = query.filter(exists(
    versions::table
        .filter(versions::crate_id.eq(crates::id))
        .filter(versions::yanked.eq(false))
));

from above in each of the user_id= and team_id= sections, and that seems to work just fine.

However, I'm wondering if that's the most clear. Are we getting ourselves into a situation where we perform this logic if this is true, and that logic if that is true, and it gets tangled and confusing?

What if each front-end route is allowed to specify whether it wants to show yanked versions or not, using /api/v1/crates?include_yanked=(y|n) (or something similar)?

I would suggest we include yanked crates by default because that is how all existing requests work. And then specifically update the /users/:id and /teams/:id routes to add ?include_yanked=n to their parameters.

The advantages are that whether or not to include or exclude yanked crates is somewhat orthogonal to the other requests, and having a specific parameter for this functionality would allow front-end code to choose whether to show yanked crates or not on a route-by-route basis. For example, I could see us wanting /api/v1/crates?letter=a&include_yanked=n or something in the future, and that would be an easy change.

However, I haven't considered the database query time impact. And I could be convinced that this extensibility isn't buying us anything except complexity.

Is this a path worth pursuing?


I tried it out and I imagine it looking something like this: bryanburgers@1ebfc08

bryanburgers added a commit to bryanburgers/crates.io that referenced this issue Feb 28, 2019
Add a URL parameter to the `/api/v1/crates` endpoint that specifies
whether or not the endpoint should return crates that have been fully
yanked - i.e., where every version has been yanked.

If not specified, this defaults to `true` because we have typically
always returned all matching crates, whether or not their versions have
been yanked.

This makes it possible to display only non-yanked crates at various
places in the UI, and is especially intended for the user and team pages
to display only non-yanked crates, as discussed in rust-lang#958.
bryanburgers added a commit to bryanburgers/crates.io that referenced this issue Feb 28, 2019
Don't display crates that have been fully yanked - i.e., crates that
where every version has been yanked - on user and team pages.

Closes rust-lang#958
bryanburgers added a commit to bryanburgers/crates.io that referenced this issue Feb 28, 2019
Don't display crates that have been fully yanked - i.e., crates that
where every version has been yanked - on user and team pages.

Closes rust-lang#958
bors added a commit that referenced this issue May 22, 2019
…-pages, r=sgrif

Exclude yanked crates on user/team pages

Add a URL parameter to the `/api/v1/crates` endpoint that specifies whether or not the endpoint should return crates that have been fully yanked - i.e., where every version has been yanked.

If not specified, this defaults to `true` because we have typically always returned all matching crates, whether or not their versions have been yanked.

This makes it possible to display only non-yanked crates at various places in the UI without changing Rust code.

Use this from the user and team pages to exclude yanked crates from them.

Closes #958
bors added a commit that referenced this issue May 22, 2019
…-pages, r=sgrif

Exclude yanked crates on user/team pages

Add a URL parameter to the `/api/v1/crates` endpoint that specifies whether or not the endpoint should return crates that have been fully yanked - i.e., where every version has been yanked.

If not specified, this defaults to `true` because we have typically always returned all matching crates, whether or not their versions have been yanked.

This makes it possible to display only non-yanked crates at various places in the UI without changing Rust code.

Use this from the user and team pages to exclude yanked crates from them.

Closes #958
bors added a commit that referenced this issue Jun 13, 2019
…-pages, r=sgrif

Exclude yanked crates on user/team pages

Add a URL parameter to the `/api/v1/crates` endpoint that specifies whether or not the endpoint should return crates that have been fully yanked - i.e., where every version has been yanked.

If not specified, this defaults to `true` because we have typically always returned all matching crates, whether or not their versions have been yanked.

This makes it possible to display only non-yanked crates at various places in the UI without changing Rust code.

Use this from the user and team pages to exclude yanked crates from them.

Closes #958
bors added a commit that referenced this issue Jun 20, 2019
…-pages, r=sgrif

Exclude yanked crates on user/team pages

Add a URL parameter to the `/api/v1/crates` endpoint that specifies whether or not the endpoint should return crates that have been fully yanked - i.e., where every version has been yanked.

If not specified, this defaults to `true` because we have typically always returned all matching crates, whether or not their versions have been yanked.

This makes it possible to display only non-yanked crates at various places in the UI without changing Rust code.

Use this from the user and team pages to exclude yanked crates from them.

Closes #958
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works E-has-mentor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants