Skip to content

A platform for community discussion. Free, open, simple.

PERF: Avoid loading the whole record when we only need id (#25301)

Andrei Prigorshnev20c5f7aef89b
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