Revert "PERF: Use 1 query to load group and tag notification default."

This reverts commit 5ef9d4d537.

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.
This commit is contained in:
Joshua Rosenfeld 2020-09-10 08:52:53 -04:00
parent d84dee4519
commit 86764f3aac
No known key found for this signature in database
GPG Key ID: BFD6217DEA2C0A95
1 changed files with 2 additions and 14 deletions

View File

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