Skip to content

A platform for community discussion. Free, open, simple.

PERF: avoid using destroy_all when removing stats (#11358)

Sam97eae4e3add4
diff --git a/app/services/destroy_task.rb b/app/services/destroy_task.rb
index a366312cb95..57afc0e3d72 100644
--- a/app/services/destroy_task.rb
+++ b/app/services/destroy_task.rb
@@ -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