PERF: avoid query as admin
As admin no need to query categories over and over
This commit is contained in:
parent
47ce674798
commit
e232f87cde
|
@ -43,9 +43,12 @@ class Site
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
allowed_topic_create_ids =
|
allowed_topic_create = nil
|
||||||
@guardian.anonymous? ? [] : Category.topic_create_allowed(@guardian).pluck(:id)
|
unless @guardian.is_admin?
|
||||||
allowed_topic_create = Set.new(allowed_topic_create_ids)
|
allowed_topic_create_ids =
|
||||||
|
@guardian.anonymous? ? [] : Category.topic_create_allowed(@guardian).pluck(:id)
|
||||||
|
allowed_topic_create = Set.new(allowed_topic_create_ids)
|
||||||
|
end
|
||||||
|
|
||||||
by_id = {}
|
by_id = {}
|
||||||
|
|
||||||
|
@ -58,7 +61,7 @@ class Site
|
||||||
|
|
||||||
categories.each do |category|
|
categories.each do |category|
|
||||||
category.notification_level = category_user[category.id] || regular
|
category.notification_level = category_user[category.id] || regular
|
||||||
category.permission = CategoryGroup.permission_types[:full] if allowed_topic_create.include?(category.id)
|
category.permission = CategoryGroup.permission_types[:full] if allowed_topic_create&.include?(category.id) || @guardian.is_admin?
|
||||||
category.has_children = with_children.include?(category.id)
|
category.has_children = with_children.include?(category.id)
|
||||||
by_id[category.id] = category
|
by_id[category.id] = category
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue