mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 20:12:45 +08:00
PERF: avoid using destroy_all when removing stats (#11358)
destroy_all will load all the active record relation and iterate, this can get extremely expensive.
This commit is contained in:
parent
c9df679ba1
commit
97eae4e3ad
|
@ -97,17 +97,13 @@ class DestroyTask
|
|||
end
|
||||
|
||||
def destroy_stats
|
||||
ApplicationRequest.destroy_all
|
||||
IncomingLink.destroy_all
|
||||
UserVisit.destroy_all
|
||||
UserProfileView.destroy_all
|
||||
user_profiles = UserProfile.all
|
||||
user_profiles.each do |user_profile|
|
||||
user_profile.views = 0
|
||||
user_profile.save!
|
||||
end
|
||||
PostAction.unscoped.destroy_all
|
||||
EmailLog.destroy_all
|
||||
ApplicationRequest.delete_all
|
||||
IncomingLink.delete_all
|
||||
UserVisit.delete_all
|
||||
UserProfileView.delete_all
|
||||
UserProfile.update_all(views: 0)
|
||||
PostAction.unscoped.delete_all
|
||||
EmailLog.delete_all
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in New Issue
Block a user