PERF: Remove unnecessary DB queries when preloading for chat (#19514)
Use `Chat::ChatChannelFetcher.secured_public_channel_search` directly checking for existence instead of running through `Chat::ChatChannelFetcher.secured_public_channels` which executes 7 more DB queries.
This commit is contained in:
parent
a6edd6ea61
commit
4ea6b09fc7
|
@ -416,13 +416,13 @@ after_initialize do
|
||||||
add_to_serializer(:current_user, :needs_dm_retention_reminder) { true }
|
add_to_serializer(:current_user, :needs_dm_retention_reminder) { true }
|
||||||
|
|
||||||
add_to_serializer(:current_user, :has_joinable_public_channels) do
|
add_to_serializer(:current_user, :has_joinable_public_channels) do
|
||||||
Chat::ChatChannelFetcher.secured_public_channels(
|
Chat::ChatChannelFetcher.secured_public_channel_search(
|
||||||
self.scope,
|
self.scope,
|
||||||
Chat::ChatChannelMembershipManager.all_for_user(self.scope.user),
|
|
||||||
following: false,
|
following: false,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
status: :open,
|
status: :open,
|
||||||
).present?
|
exclude_dm_channels: true
|
||||||
|
).exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
add_to_serializer(:current_user, :chat_channels) do
|
add_to_serializer(:current_user, :chat_channels) do
|
||||||
|
|
Loading…
Reference in New Issue