use cache for fetching categories

This commit is contained in:
r888888888
2017-11-15 14:44:36 -08:00
parent 071a63e934
commit e5cc6a7949

View File

@@ -141,7 +141,7 @@ class Tag < ApplicationRecord
Post.with_timeout(30_000, nil, {:tags => name}) do
Post.raw_tag_match(name).where("true /* Tag#update_category_post_counts */").find_each do |post|
post.reload
post.set_tag_counts
post.set_tag_counts(false)
args = TagCategory.categories.map {|x| ["tag_count_#{x}",post.send("tag_count_#{x}")]}.to_h.update(:tag_count => post.tag_count)
Post.where(:id => post.id).update_all(args)
end