Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/crates_io_database/src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ impl NewUser<'_> {
.do_update()
.set((
users::gh_login.eq(excluded(users::gh_login)),
users::username.eq(excluded(users::username)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should probably have a test for this change in behavior; I'm a little surprised that we don't have one that failed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Aha, this test would have failed, but it's checking users.gh_login rather than users.username. That test should be changed to username, which should pass without this change, then fail with the change, then the assertion should be changed to assert that users.username stays the same but that the oauth_github.login changes.

users::name.eq(excluded(users::name)),
users::gh_encrypted_token.eq(excluded(users::gh_encrypted_token)),
))
Expand Down
1 change: 0 additions & 1 deletion src/tests/worker/update_user_from_github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ impl UpdateTest {
// For now, we want to update the `User` record too
let user_after_update = User::find(&conn, user_id).await?;
assert_eq!(user_after_update.gh_login, expected_username);
assert_eq!(user_after_update.username, expected_username);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rather than removing this assertion, I think it should change to assert that user_after_update.username still equals existing_gh_user.login.


if job_result.is_err() {
// The worker leaves failed rows in `background_jobs` so they can
Expand Down
5 changes: 1 addition & 4 deletions src/worker/jobs/update_user_from_github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,7 @@ impl UpdateUserFromGithub {
if oauth_github.login != github_user.login {
diesel::update(users::table)
.filter(users::id.eq(oauth_github.user_id))
.set((
users::gh_login.eq(&github_user.login),
users::username.eq(&github_user.login),
))
.set(users::gh_login.eq(&github_user.login))
.execute(conn)
.await?;
}
Expand Down