From 86764f3aac9297e0638cb0843d5f401b5e8f4205 Mon Sep 17 00:00:00 2001 From: Joshua Rosenfeld Date: Thu, 10 Sep 2020 08:52:53 -0400 Subject: [PATCH] Revert "PERF: Use 1 query to load group and tag notification default." This reverts commit 5ef9d4d5371d8bad557168de643a13a483be1ebc. The reverted commit caused issues, https://meta.discourse.org/t/there-are-no-visible-groups/163604. Reverting until further fixes can be put in place. --- app/serializers/basic_group_serializer.rb | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/app/serializers/basic_group_serializer.rb b/app/serializers/basic_group_serializer.rb index 8004e7ccdc3..3fee36fcba5 100644 --- a/app/serializers/basic_group_serializer.rb +++ b/app/serializers/basic_group_serializer.rb @@ -134,23 +134,11 @@ class BasicGroupSerializer < ApplicationSerializer [:watching, :regular, :tracking, :watching_first_post, :muted].each do |level| define_method("#{level}_category_ids") do - @group_category_notification_defaults ||= begin - GroupCategoryNotificationDefault.where(group: object).pluck(:category_id) - end - - @group_category_notification_defaults.filter do |default| - default.notification_level == NotificationLevels.all[level] - end + GroupCategoryNotificationDefault.lookup(object, level).pluck(:category_id) end define_method("#{level}_tags") do - @group_tag_notification_defaults ||= begin - GroupTagNotificationDefault.where(group: object).joins(:tag).pluck('tags.name') - end - - @group_tag_notification_defaults.filter do |default| - default.notification_level == NotificationLevels.all[level] - end + GroupTagNotificationDefault.lookup(object, level).joins(:tag).pluck('tags.name') end end