mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
PERF: Move mention lookups out of the V8 context. (#6640)
We were looking up each mention one by one without any form of caching and that results in a problem somewhat similar to an N+1. When we have to do alot of DB lookups, it also increased the time spent in the V8 context which may eventually lead to a timeout. The change here makes it such that mention lookups only does a single DB query per post that happens outside of the V8 context.
This commit is contained in:
@ -39,12 +39,6 @@ module PrettyText
|
||||
username
|
||||
end
|
||||
|
||||
def mention_lookup(name)
|
||||
return false if name.blank?
|
||||
return "user" if User.exists?(username_lower: name.downcase)
|
||||
return "group" if Group.exists?(name: name)
|
||||
end
|
||||
|
||||
def category_hashtag_lookup(category_slug)
|
||||
if category = Category.query_from_hashtag_slug(category_slug)
|
||||
[category.url_with_id, category_slug]
|
||||
|
Reference in New Issue
Block a user