mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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
|
end
|
||||||
|
|
||||||
def destroy_stats
|
def destroy_stats
|
||||||
ApplicationRequest.destroy_all
|
ApplicationRequest.delete_all
|
||||||
IncomingLink.destroy_all
|
IncomingLink.delete_all
|
||||||
UserVisit.destroy_all
|
UserVisit.delete_all
|
||||||
UserProfileView.destroy_all
|
UserProfileView.delete_all
|
||||||
user_profiles = UserProfile.all
|
UserProfile.update_all(views: 0)
|
||||||
user_profiles.each do |user_profile|
|
PostAction.unscoped.delete_all
|
||||||
user_profile.views = 0
|
EmailLog.delete_all
|
||||||
user_profile.save!
|
|
||||||
end
|
|
||||||
PostAction.unscoped.destroy_all
|
|
||||||
EmailLog.destroy_all
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
Loading…
Reference in New Issue
Block a user