DEV: Reduce duplication (#26329)

This commit is contained in:
Daniel Waterworth 2024-03-25 11:56:32 -05:00 committed by GitHub
parent 8f44b805f6
commit 739a139bcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 16 deletions

View File

@ -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