Skip to content

Record who published crate versions #1561

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

Conversation

Andy-Bell
Copy link
Contributor

This PR is designed to address #1478.

I believe it answers all the check boxes listed there, but I am not 100% happy on how I have fixed the tests in the last commit here (there may not need to be the passing of the user_id values quite as much?).

Also the EncodableVersion just provides the ID of the Owner, not the full struct of EncodableOwner, as I could not work out how to do that cleanly - any insight would be appreciated

Andy-Bell and others added 7 commits November 24, 2018 22:17
field to the versions table. Also updates the
schema.rb to reflect this table change.

published by is a foreign key referencing the
users table.
match the Version Struct correctly. Fixes test in
the same file broken by this change
creation of the new versions in the krate
publish controller and in the update-downloads
bin
by adding in user_id arguments to pass it through.
Unsure if this is the best way to solve this issue
in the tests.
@carols10cents
Copy link
Member

Ugh github is being weird, it won't let me comment on lines. So here's my review:

  • The published_by column actually needs to be nullable (so remove the NOT NULL constraint from the migration); we won't have this information for any versions published before this change gets deployed.

  • That also means the published_by field on the Version struct should be type Option<i32>

  • I think I moved the VersionBuilder and CrateBuilder out from underneath you; they're now in src/tests/builders.rs. Mind moving your changes over there and removing the ones that are showing as added in this PR?

  • Is there a reason you pass self.owner_id from CrateBuilder expect_build to CrateBuilder build? build can just use self.owner_id directly like it does in this spot rather than using the user_id parameter, right? I guess that's what you meant in the PR description by "(there may not need to be the passing of the user_id values quite as much?)", I think you're correct :)

I'm taking a look at what problems you might have encountered when trying to add the full struct of EncodableOwner to EncodableVersion now...

@carols10cents
Copy link
Member

Ok, so for including the information with the EncodableVersion:

  • Taking a closer look, I think it actually makes more sense for published_by to be an EncodablePublicUser, not an EncodableOwner (because this will always be a person who typed cargo publish, not a team).
  • As far as how to implement this, what about taking a User as an argument to Version encode, and then wherever we query to get versions to pass to encode, such as in the krate metadata controller, we also join to the users table on published_by?
  • Then Version encode can call encodable_public on that user to get an EncodablePublicUser.

Does that make sense? Would that solve whatever problems you were running into or no? Please ask more questions if I've guessed wrong!

@carols10cents
Copy link
Member

I think moving your changes on CrateBuilder and VersionBuilder to the builders.rs file should fix the travis failures.

Andy-Bell and others added 5 commits November 29, 2018 22:24
published by is a nullable field now.
be part of their own builders.rs file and this PR
accidentally merged them back into the all.rs file
when trying to resolve the merge conflict. This
commit removes them from all.rs so that it reflects
master, and then makes the minimal changes needed to
the models in builders.rs to reflect the new database
updates.
@bors
Copy link
Contributor

bors commented Feb 3, 2019

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

@carols10cents
Copy link
Member

Hi @Andy-Bell, I hope you don't mind, but I'm planning on building off what you've started here for the time-sensitive requiring of verified email addresses to publish crates, so I finished the last piece of returning an EncodablePublicUser from the HTTP API. The queries were a bit tricky to get right actually! So no worries!

Because I've now contributed some stuff to this PR, I think someone else should review and merge this, at least my commits. Yours look great to me, thank you so much!

@carols10cents
Copy link
Member

I incorporated this PR into #1621, so it's going to get merged when that gets merged. Thank you @Andy-Bell!!!

bors added a commit that referenced this pull request Feb 22, 2019
Record verified email, if present, of the publisher in the version record

Connects to #1620. We can start recording emails if we have them, even though we're not requiring verified emails yet.

This builds on top of #1561.
bors added a commit that referenced this pull request Feb 22, 2019
Record verified email, if present, of the publisher in the version record

Connects to #1620. We can start recording emails if we have them, even though we're not requiring verified emails yet.

This builds on top of #1561.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants