get rid of N+1 query in `notification_count` method
This commit is contained in:
parent
5a0e42fe66
commit
19e5837ce5
|
@ -22,11 +22,10 @@ module ApplicationHelper
|
|||
def notification_count
|
||||
return 0 unless user_signed_in?
|
||||
|
||||
count = Notification.for(current_user).where(new: true)
|
||||
return nil if count.nil?
|
||||
return nil unless count.count.positive?
|
||||
count = Notification.for(current_user).where(new: true).pluck(:id).size
|
||||
return nil unless count.positive?
|
||||
|
||||
count.count
|
||||
count
|
||||
end
|
||||
|
||||
def privileged?(user)
|
||||
|
|
Loading…
Reference in New Issue