Skip to content

Commit

Permalink
Don't lookup category names if tag tree view all
Browse files Browse the repository at this point in the history
This was executing a few hundred extra queries

category.name is the culprit

https://bugzilla.redhat.com/show_bug.cgi?id=1399345
  • Loading branch information
kbrock committed Jan 4, 2017
1 parent e36f61b commit 0a4598a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/presenters/tree_builder_tags.rb
Expand Up @@ -45,16 +45,23 @@ def root_options

def x_get_tree_roots(count_only, _options)
# open node if at least one of his kids is selected
@categories.each do |c|
open_node("cl-#{to_cid(c.id)}") if contain_selected_kid(c)
if @edit.present? || @filters.present?
@categories.each do |c|
open_node("cl-#{to_cid(c.id)}") if contain_selected_kid(c)
end
end
count_only_or_objects(count_only, @categories)
end

def x_get_classification_kids(parent, count_only)
return parent.entries.size if count_only
kids = parent.entries.map do |kid|
kid_id = "#{parent.name}-#{kid.name}"
select = (@edit && @edit.fetch_path(:new, :filters, kid_id)) || (@filters && @filters.key?(kid_id))
select = if @edit.blank? && @filters.blank?
false
else
kid_id = "#{parent.name}-#{kid.name}"
(@edit && @edit.fetch_path(:new, :filters, kid_id)) || (@filters && @filters.key?(kid_id))
end
{:id => kid.id,
:image => '100/tag.png',
:text => kid.description,
Expand Down

0 comments on commit 0a4598a

Please sign in to comment.