diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2017-02-06 14:48:27 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2017-02-24 14:20:19 +0300 |
commit | 53c34c7436112d7cac9c3887ada1d5ae630a206c (patch) | |
tree | 6a3262eef1760c3aa3d88ef9bc57b3f88bb85ceb /app/services | |
parent | ca16c3734b7b89f71bdc9e1c18152aa1599c4f89 (diff) |
Implement review comments from @DouweM and @nick.thomas.
1. Use an advisory lock to guarantee the absence of concurrency in `User.ghost`,
to prevent data races from creating more than one ghost, or preventing the
creation of ghost users by causing validation errors.
2. Use `update_all` instead of updating issues one-by-one.
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/users/destroy_service.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/services/users/destroy_service.rb b/app/services/users/destroy_service.rb index d88b81c04e2..bf1e49734cc 100644 --- a/app/services/users/destroy_service.rb +++ b/app/services/users/destroy_service.rb @@ -37,12 +37,12 @@ module Users end private - + def move_issues_to_ghost_user(user) ghost_user = User.ghost Issue.transaction do - user.issues.each { |issue| issue.update!(author: ghost_user) } + user.issues.update_all(author_id: ghost_user.id) end user.reload |