PERF: Try to match users before groups.

User mentions are more common than group mentions so
this will allow us to avoid an extra query.
This commit is contained in:
Guo Xiang Tan
2018-11-16 16:41:20 +08:00
parent 44d7249a17
commit 45f299dfdd
2 changed files with 9 additions and 1 deletions

View File

@ -41,8 +41,8 @@ module PrettyText
def mention_lookup(name)
return false if name.blank?
return "group" if Group.exists?(name: name)
return "user" if User.exists?(username_lower: name.downcase)
return "group" if Group.exists?(name: name)
end
def category_hashtag_lookup(category_slug)