eliminate tag cache expiry delayed job

This commit is contained in:
Albert Yi
2018-10-11 16:36:50 -07:00
parent e329764276
commit 185d303ba1
2 changed files with 2 additions and 7 deletions

View File

@@ -20,6 +20,6 @@ class TagCorrection
def fix!
tag.delay(:queue => "default").fix_post_count
tag.update_category_cache_for_all
tag.update_category_cache
end
end

View File

@@ -21,7 +21,7 @@ class Tag < ApplicationRecord
validates :name, uniqueness: true, tag_name: true, on: :create
validates_inclusion_of :category, in: TagCategory.category_ids
after_save :update_category_cache_for_all, if: ->(rec) { rec.saved_change_to_attribute?(:category)}
after_save :update_category_cache, if: ->(rec) { rec.saved_change_to_attribute?(:category)}
module ApiMethods
def to_legacy_json
@@ -137,11 +137,6 @@ class Tag < ApplicationRecord
TagCategory.reverse_mapping[category].capitalize
end
def update_category_cache_for_all
update_category_cache
delay(:queue => "default", :priority => 10).update_category_post_counts
end
def update_category_post_counts
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|