mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-15 20:19:59 +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
|
||||
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 a new issue