switch to use Cache.get_multi for tag types

This commit is contained in:
r888888888
2017-03-17 18:36:53 -07:00
parent c5cfca3a3c
commit 5cef0321f2
2 changed files with 3 additions and 4 deletions

View File

@@ -102,9 +102,8 @@ class Tag < ActiveRecord::Base
end
def categories_for(tag_names, options = {})
Array(tag_names).inject({}) do |hash, tag_name|
hash[tag_name] = category_for(tag_name, options)
hash
categories = Cache.get_multi(Array(tag_names), "tc") do |tag|
Tag.select_category_for(tag)
end
end
end

View File

@@ -68,7 +68,7 @@ class TagSetPresenter < Presenter
def inline_tag_list(template)
@tags.map do |tag_name|
<<-EOS
<span class="category-#{Tag.category_for(tag_name)}">
<span class="category-#{categories[tag_name]}">
#{template.link_to(tag_name.tr("_", " "), template.posts_path(tags: tag_name))}
</span>
EOS