DEV: Reduce duplication (#26329)
This commit is contained in:
parent
8f44b805f6
commit
739a139bcf
|
@ -207,22 +207,7 @@ class CategoryList
|
|||
@categories.delete_if { |c| to_delete.include?(c) }
|
||||
end
|
||||
|
||||
allowed_topic_create = Set.new(Category.topic_create_allowed(@guardian).pluck(:id))
|
||||
|
||||
parent_ids =
|
||||
Category
|
||||
.secured(@guardian)
|
||||
.where(parent_category_id: categories_with_descendants.map(&:id))
|
||||
.pluck("DISTINCT parent_category_id")
|
||||
.to_set
|
||||
|
||||
categories_with_descendants.each do |category|
|
||||
category.notification_level = notification_levels[category.id] || default_notification_level
|
||||
category.permission = CategoryGroup.permission_types[:full] if allowed_topic_create.include?(
|
||||
category.id,
|
||||
)
|
||||
category.has_children = parent_ids.include?(category.id)
|
||||
end
|
||||
Category.preload_user_fields!(@guardian, categories_with_descendants)
|
||||
end
|
||||
|
||||
def prune_empty
|
||||
|
|
Loading…
Reference in New Issue