From f9e6e5a66ad1100781bd0bdaf0b56e9e34bfdd44 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 20 Dec 2015 17:47:02 +1100 Subject: [PATCH] PERF: properly preload all category notification levels --- app/models/site.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/site.rb b/app/models/site.rb index 3459947b73c..3a3d0396a71 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -53,8 +53,10 @@ class Site category_user = Hash[*CategoryUser.where(user: @guardian.user).pluck(:category_id, :notification_level).flatten] end + regular = CategoryUser.notification_levels[:regular] + categories.each do |category| - category.notification_level = category_user[category.id] + category.notification_level = category_user[category.id] || regular category.permission = CategoryGroup.permission_types[:full] if allowed_topic_create.include?(category.id) category.has_children = with_children.include?(category.id) by_id[category.id] = category