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

Handle deleted user accounts for code review #46520

Merged
merged 6 commits into from
May 27, 2022

Conversation

molly-moen
Copy link
Contributor

@molly-moen molly-moen commented May 25, 2022

On user account delete, do the following:

  • set the commenter id on any code review notes the user wrote to null.
  • set the comment on any code review notes the user wrote to null
  • soft delete any code reviews for the user and any notes on those code reviews. Also null out comments on those reviews.

Links

Testing story

Tested via unit tests.

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@molly-moen molly-moen requested review from a team May 25, 2022 19:46
comments_written = CodeReviewNote.where(commenter_id: user_id)
comments_written_count = comments_written.count
comments_written.each do |comment|
comment.commenter_id = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this is how the Jira ticket is written, but surprised we're not deleting the contents of the comment? For future reference, @maureensturgeon could you clarify the reasoning here? Do we need to keep comments for legal reasons or something?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is what was requested by Mike, I think so that if someone looks back at their code review they can still see the comments that they were given

# soft delete the code reviews of the user. This also soft deletes any comments on those reviews.
code_reviews = CodeReview.where(user_id: user_id)
code_reviews_count = code_reviews.count
code_reviews.destroy_all
Copy link
Contributor

Choose a reason for hiding this comment

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

How do the comments (associated code review notes) get deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They get deleted via the dependent: :destroy in code_review

@bencodeorg
Copy link
Contributor

Sorry for approving then raising a bunch of noise on this :) FWIW I think its fine to merge and then get clarity on the privacy question, but I don't think this would really block any other work so maybe just better to wait to clear things up.

Copy link
Contributor

@maureensturgeon maureensturgeon left a comment

Choose a reason for hiding this comment

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

Looks good, just pending the privacy conversation

@molly-moen
Copy link
Contributor Author

after further discussion I created this PR to allow the comment to be null. After that's in I will update this PR to null out comments on user delete.

@molly-moen
Copy link
Contributor Author

@maureensturgeon @bencodeorg updated with new logic after discussion.

Copy link
Contributor

@bencodeorg bencodeorg left a comment

Choose a reason for hiding this comment

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

LGTM!

# Table: dashboard.code_review_requests
# Table: dashboard.code_review_notes
#
test "soft deletes comments for purged user" do
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: maybe an update to this test name that notes there's some hard deleting going on this case, and aligns with the naming in the next test? Maybe "deletes code review comments on reviews owned by purged user"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call

refute_nil comment.commenter
end

test "anonymizes and deletes code review comments written by user" do
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we don't need to anonymize them anymore since they're just getting deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since we are soft-deleting I'm still anonymizing

@molly-moen molly-moen merged commit d4c488d into staging May 27, 2022
@molly-moen molly-moen deleted the molly/deleted-user-code-review branch May 27, 2022 18:59
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.

None yet

3 participants