search: save a query in fast_count (#4120).
During single-tag searches we look up the tag once in Post.fast_count and later on when rendering the wiki excerpt. Doing a raw query here meant that Rails couldn't cache the query, so it got ran again when rendering the excerpt.
This commit is contained in:
@@ -1177,7 +1177,7 @@ class Post < ApplicationRecord
|
|||||||
|
|
||||||
def get_count_from_cache(tags)
|
def get_count_from_cache(tags)
|
||||||
if Tag.is_simple_tag?(tags)
|
if Tag.is_simple_tag?(tags)
|
||||||
count = select_value_sql("SELECT post_count FROM tags WHERE name = ?", tags.to_s)
|
count = Tag.find_by(name: tags).try(:post_count)
|
||||||
else
|
else
|
||||||
# this will only have a value for multi-tag searches or single metatag searches
|
# this will only have a value for multi-tag searches or single metatag searches
|
||||||
count = Cache.get(count_cache_key(tags))
|
count = Cache.get(count_cache_key(tags))
|
||||||
|
|||||||
Reference in New Issue
Block a user