mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-15 23:20:01 +01:00
get rid of N+1 query in notification_count
method
This commit is contained in:
parent
5a0e42fe66
commit
19e5837ce5
1 changed files with 3 additions and 4 deletions
|
@ -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 a new issue