-
Notifications
You must be signed in to change notification settings - Fork 600
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
Crates who have yanked all their versions should only return name, owners, and that it's yanked #1058
Comments
I'd like to work on this. It'll be my first Rust code contribution! Thanks for making it so accessible to new people ❤️ I actually got here from the RustConf keynote on YouTube. |
Hi @seanlinsley!!! It's awesome to have you!! Please let me know if you have any questions ❤️ |
When running
The backend server appears to boot, though some tables are missing when running the tests: ---- category::tests::category_toplevel_includes_subcategories_in_crate_cnt stdout ----
thread 'category::tests::category_toplevel_includes_subcategories_in_crate_cnt' panicked at 'called `Result::unwrap()` on an `Err` value: DatabaseError(__Unknown, "relation \"categories\" does not exist")', src/libcore/result.rs:860:4
---- category::tests::category_toplevel_applies_limit_and_offset stdout ----
thread 'category::tests::category_toplevel_applies_limit_and_offset' panicked at 'called `Result::unwrap()` on an `Err` value: DatabaseError(__Unknown, "relation \"categories\" does not exist")', src/libcore/result.rs:860:4
---- category::tests::category_toplevel_orders_by_crates_cnt_when_sort_given stdout ----
thread 'category::tests::category_toplevel_orders_by_crates_cnt_when_sort_given' panicked at 'called `Result::unwrap()` on an `Err` value: DatabaseError(__Unknown, "relation \"categories\" does not exist")', src/libcore/result.rs:860:4
---- category::tests::category_toplevel_applies_limit_and_offset_after_grouping stdout ----
thread 'category::tests::category_toplevel_applies_limit_and_offset_after_grouping' panicked at 'called `Result::unwrap()` on an `Err` value: DatabaseError(__Unknown, "relation \"categories\" does not exist")', src/libcore/result.rs:860:4
---- category::tests::category_toplevel_excludes_subcategories stdout ----
thread 'category::tests::category_toplevel_excludes_subcategories' panicked at 'called `Result::unwrap()` on an `Err` value: DatabaseError(__Unknown, "relation \"categories\" does not exist")', src/libcore/result.rs:860:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.
---- keyword::tests::dont_associate_with_non_lowercased_keywords stdout ----
thread 'keyword::tests::dont_associate_with_non_lowercased_keywords' panicked at 'called `Result::unwrap()` on an `Err` value: DatabaseError(__Unknown, "relation \"keywords\" does not exist")', src/libcore/result.rs:860:4
failures:
category::tests::category_toplevel_applies_limit_and_offset
category::tests::category_toplevel_applies_limit_and_offset_after_grouping
category::tests::category_toplevel_excludes_subcategories
category::tests::category_toplevel_includes_subcategories_in_crate_cnt
category::tests::category_toplevel_orders_by_crates_cnt_when_sort_given
keyword::tests::dont_associate_with_non_lowercased_keywords
test result: FAILED. 12 passed; 6 failed; 0 ignored; 0 measured; 0 filtered out The setup instructions say that A caveat was that I ran These were the exact errors: # I hadn't set up `.env` yet
$ diesel migration run
The --database-url argument must be passed, or the DATABASE_URL environment variable must be set.
# Homebrew's install doesn't provide a postgres user
$ diesel migration run
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ConnectionError(BadConnection("FATAL: role \"postgres\" does not exist\n"))', src/libcore/result.rs:860:4
note: Run with `RUST_BACKTRACE=1` for a backtrace. |
Indeed, the test database has no tables in it. |
Oddly |
It's a clap bug. clap-rs/clap#978 Unfortunately you need to do |
If you have |
The trick is that I'm not sure how to fix the underlying issue, ideas welcome over at #988. In the meantime, @seanlinsley, if you change a test file and run |
Sorry for the delay on this; picking it back up today. |
I didn't delete the database myself like described in #988. I thought I'd seen an exception during the test setup when running |
|
It looks like the show action uses Both the show & index actions already load all versions into memory: Lines 880 to 882 in ef1ac58
Lines 736 to 740 in ef1ac58
So it may be more efficient to construct this attribute in memory, instead of doing another database request. This should work for the show page: let all_versions_yanked = versions.iter().any(|v| !v.yanked).collect(); For the index page, I was thinking of updating the existing @@ -744,7 +748,7 @@ pub fn index(req: &mut Request) -> CargoResult<Response> {
.zip(perfect_matches)
.zip(recent_downloads)
.map(
- |(((max_version, krate), perfect_match), recent_downloads)| {
+ |((((max_version, all_versions_yanked), krate), perfect_match), recent_downloads)| {
// FIXME: If we add crate_id to the Badge enum we can eliminate
// this N+1
let badges = badges::table I'm not totally happy with that though; it seems like that code has a tendency to become more and more nested. I'll also need to learn a bit more Rust to write it 😄 |
Using Lines 602 to 615 in ef1ac58
The Lines 797 to 802 in ef1ac58
I'm tempted to update |
Ah, the problem with that is that the versions already loaded are excluding yanked versions. Another thing to note is that it's not as simple as |
I'm having trouble figuring out how to get |
Unsure if the
From this code: pub fn encodable(
self,
versions: Vec<Version>,
keywords: Option<&[Keyword]>,
categories: Option<&[Category]>,
badges: Option<Vec<Badge>>,
exact_match: bool,
recent_downloads: Option<i64>,
) -> EncodableCrate {
let (versions, yanked_versions) = versions.into_iter().partition(|v| !v.yanked);
let max_version = Version::max(versions.into_iter().map(|v| v.num));
let all_versions_yanked = yanked_versions.len() > 0 && versions.len() == 0; Which is odd, because the line right above that doesn't have an issue calling |
Ah, I guess the extra call to |
Nope, it's still a problem when defining it to a new variable: let (live_versions, yanked_versions) = versions.into_iter().partition(|v| !v.yanked);
let max_version = Version::max(live_versions.map(|v| v.num)); |
This is the first version I've written that compiles 🎉 let (live_versions, yanked_versions): (Vec<Version>, Vec<Version>) = versions.into_iter().partition(|v| !v.yanked);
let live_versions = live_versions.into_iter();
let version_ids = live_versions.clone().map(|v| v.id);
let max_version = Version::max(live_versions.clone().map(|v| v.num));
let all_versions_yanked = yanked_versions.len() > 0 && live_versions.len() == 0; It certainly seems far from optimal, having to call |
Hi, if no one is working on this issue I want to pick it up :3 |
Hi @hbina, sorry for the delay in responding, no one is currently working on this that I know of so please feel free if you're still interested! |
Is anyone currently working on this? If not would I be able to take it on? |
I don't know of any work being done on this right now, please go ahead! Let me know if you have any questions! |
Hey there! Anyone working on this one right now? Also, would this be a good first issue for someone completely new to the language :)? Cheers! |
@willolisp I don't think there's anyone working on it, and yes, I think this would be a good first issue! Please ask if you have questions, thanks! |
@carols10cents cool! Then I'll give this one a try. Thanks so much! |
Hey 👋 Is anyone working on this at the moment? If not, I would like to tackle this issue. @carols10cents Assuming I can work on this, should EncodableCrate::from_minimal also support all_versions_yanked? |
@hayleyjames I would expect any progress on this to be shown on the issue or in a connected PR, so it looks like no one is working on this right now!
Yes, on a quick glance, I think so, because |
@carols10cents Thanks! I'll start working on this. |
Hi @carols10cents I put a PR together for this issue based on the comments from this issue: #5314 This is my first PR in Rust, so I probably did some silly mistakes 😅 . Let me know what needs to be changed and I will keep working on it :) |
we talked about this situation in the crates.io team meeting last week and decided that we would like to change course on this issue. only displaying reduced information has quite a few downsides (e.g. who do you contact to maybe take over ownership of the crate) and we would prefer to display yanked crates/versions like their unyanked counterparts, but with some sort of banner that makes it very visible that the users is looking at a yanked crate/version. since this is a significant change to the original issue description I'll close this issue and create a new one, based on the above. |
In search results and on the crate's page, we should be displaying crates with all of their versions yanked (henceforth referred to as "yanked crates") differently (#145), but the backend needs to tell the frontend that a crate is in this state.
Instructions for fixing this:
all_versions_yanked
toEncodableCrate
and everywhere we createEncodableCrate
instances, set that field to false if there exists any non-yanked versions for this crate. I'd recommend doing aselect(exists())
query using diesel similar to this queryEncodableCrate
instance for a yanked crate, these fields should be changed too:badges
,description
,homepage
,documentation
, andrepository
should beNone
max_version
should be"0.0.0"
Some other fields, like keywords and categories, are used for search/crate lists, and this issue isn't going to change search results, so I think we should still display why a crate showed up in a particular list of crates.
The text was updated successfully, but these errors were encountered: