PERF: Update UserDestroyer to fetch histories and actions in batch (#16316)
This is much more memory-efficient when there are 1000s of rows
This commit is contained in:
parent
58d6e4e233
commit
7a284164ce
|
@ -40,14 +40,14 @@ class UserDestroyer
|
||||||
delete_posts(user, category_topic_ids, opts)
|
delete_posts(user, category_topic_ids, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
user.post_actions.each do |post_action|
|
user.post_actions.find_each do |post_action|
|
||||||
post_action.remove_act!(Discourse.system_user)
|
post_action.remove_act!(Discourse.system_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add info about the user to staff action logs
|
# Add info about the user to staff action logs
|
||||||
UserHistory.staff_action_records(
|
UserHistory.staff_action_records(
|
||||||
Discourse.system_user, acting_user: user.username
|
Discourse.system_user, acting_user: user.username
|
||||||
).each do |log|
|
).find_each do |log|
|
||||||
log.details ||= ''
|
log.details ||= ''
|
||||||
log.details = (log.details.split("\n") +
|
log.details = (log.details.split("\n") +
|
||||||
["user_id: #{user.id}", "username: #{user.username}"]
|
["user_id: #{user.id}", "username: #{user.username}"]
|
||||||
|
|
Loading…
Reference in New Issue