TagSetPresenter: refactor *_tag_list_html to avoid memcache calls.

Refactor the tag set presenter to get both the tag categories and the
tag counts in the same call to the database, instead of getting the
counts from the db and the categories from memcache.
This commit is contained in:
evazion
2018-09-30 13:21:12 -05:00
parent 99632d5e8a
commit b1f2096d72
2 changed files with 38 additions and 45 deletions

View File

@@ -56,10 +56,6 @@ class Tag < ApplicationRecord
extend ActiveSupport::Concern
module ClassMethods
def counts_for(tag_names)
select_all_sql("SELECT name, post_count FROM tags WHERE name IN (?)", tag_names)
end
def highest_post_count
Cache.get("highest-post-count", 4.hours) do
select("post_count").order("post_count DESC").first.post_count