Skip to content

Commit

Permalink
remove n+1 query from user#tagnames method (publiclab#8190)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlazypanda authored and shubhangikori committed Oct 12, 2020
1 parent 88436ae commit de0a69e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def normal_tags

def tagnames(limit = 20, defaults = true)
tagnames = []
Node.order('nid DESC').where(type: 'note', status: 1, uid: id).limit(limit).each do |node|
Node.includes(:tag).order('nid DESC').where(type: 'note', status: 1, uid: id).limit(limit).each do |node|
tagnames += node.tags.collect(&:name)
end
tagnames.uniq
Expand Down

0 comments on commit de0a69e

Please sign in to comment.