Optimize data query in user_notification.rb

This commit is contained in:
Luka Murn 2016-10-05 16:19:59 +02:00
parent c37885692d
commit 56d2240de5

View file

@ -23,9 +23,6 @@ class UserNotification < ActiveRecord::Base
end
def self.seen_by_user(user)
where(user: user).map do |n|
n.checked = true
n.save
end
where(user: user).where(checked: false).update_all(checked: true)
end
end