use ActiveRecord#find_each to prevent memory spikes in our workers
This commit is contained in:
parent
3a0c9893e7
commit
66911801f7
3 changed files with 3 additions and 3 deletions
|
|
@ -30,7 +30,7 @@ class AdminsController < ApplicationController
|
||||||
def weekly_user_stats
|
def weekly_user_stats
|
||||||
@created_users = User.where("username IS NOT NULL and created_at IS NOT NULL")
|
@created_users = User.where("username IS NOT NULL and created_at IS NOT NULL")
|
||||||
@created_users_by_week = Hash.new{ |h,k| h[k] = [] }
|
@created_users_by_week = Hash.new{ |h,k| h[k] = [] }
|
||||||
@created_users.each do |u|
|
@created_users.find_each do |u|
|
||||||
unless u.nil?
|
unless u.nil?
|
||||||
@created_users_by_week[u.created_at.beginning_of_week.strftime("%Y-%m-%d")].push("#{u.username}")
|
@created_users_by_week[u.created_at.beginning_of_week.strftime("%Y-%m-%d")].push("#{u.username}")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ module Workers
|
||||||
users = User.where(:id => user_ids)
|
users = User.where(:id => user_ids)
|
||||||
person = Person.find_by_id(person_id)
|
person = Person.find_by_id(person_id)
|
||||||
|
|
||||||
users.each{|user| Notification.notify(user, object, person) }
|
users.find_each{|user| Notification.notify(user, object, person) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ class Postzord::Receiver::LocalBatch < Postzord::Receiver
|
||||||
# return [void]
|
# return [void]
|
||||||
def notify_users
|
def notify_users
|
||||||
return unless @object.respond_to?(:notification_type)
|
return unless @object.respond_to?(:notification_type)
|
||||||
@users.each do |user|
|
@users.find_each do |user|
|
||||||
Notification.notify(user, @object, @object.author)
|
Notification.notify(user, @object, @object.author)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue