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

This commit is contained in:
Andrei Prigorshnev
2024-01-18 04:50:26 +04:00
committed by GitHub
parent 26698ff52a
commit 20c5f7aef8

View File

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