From 20c5f7aef89b6eca27d7f4816ab8158b54baf48f Mon Sep 17 00:00:00 2001 From: Andrei Prigorshnev Date: Thu, 18 Jan 2024 04:50:26 +0400 Subject: [PATCH] PERF: Avoid loading the whole record when we only need id (#25301) --- plugins/chat/app/jobs/regular/chat/notify_mentioned.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chat/app/jobs/regular/chat/notify_mentioned.rb b/plugins/chat/app/jobs/regular/chat/notify_mentioned.rb index 9e101aa53b4..5b472be3cd7 100644 --- a/plugins/chat/app/jobs/regular/chat/notify_mentioned.rb +++ b/plugins/chat/app/jobs/regular/chat/notify_mentioned.rb @@ -161,7 +161,7 @@ module Jobs target_id = user_id elsif mention_klass == ::Chat::GroupMention begin - target_id = Group.where("LOWER(name) = ?", "#{mention_type}").first.id + target_id = Group.where("LOWER(name) = ?", "#{mention_type}").pick(:id) rescue => e Discourse.warn_exception(e, message: "Mentioned group doesn't exist") end