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
|
def notification_count
|
||||||
return 0 unless user_signed_in?
|
return 0 unless user_signed_in?
|
||||||
|
|
||||||
count = Notification.for(current_user).where(new: true)
|
count = Notification.for(current_user).where(new: true).pluck(:id).size
|
||||||
return nil if count.nil?
|
return nil unless count.positive?
|
||||||
return nil unless count.count.positive?
|
|
||||||
|
|
||||||
count.count
|
count
|
||||||
end
|
end
|
||||||
|
|
||||||
def privileged?(user)
|
def privileged?(user)
|
||||||
|
|
Loading…
Reference in New Issue