eliminate tag cache expiry delayed job
This commit is contained in:
@@ -20,6 +20,6 @@ class TagCorrection
|
|||||||
|
|
||||||
def fix!
|
def fix!
|
||||||
tag.delay(:queue => "default").fix_post_count
|
tag.delay(:queue => "default").fix_post_count
|
||||||
tag.update_category_cache_for_all
|
tag.update_category_cache
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Tag < ApplicationRecord
|
|||||||
validates :name, uniqueness: true, tag_name: true, on: :create
|
validates :name, uniqueness: true, tag_name: true, on: :create
|
||||||
validates_inclusion_of :category, in: TagCategory.category_ids
|
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
|
module ApiMethods
|
||||||
def to_legacy_json
|
def to_legacy_json
|
||||||
@@ -137,11 +137,6 @@ class Tag < ApplicationRecord
|
|||||||
TagCategory.reverse_mapping[category].capitalize
|
TagCategory.reverse_mapping[category].capitalize
|
||||||
end
|
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
|
def update_category_post_counts
|
||||||
Post.with_timeout(30_000, nil, {:tags => name}) do
|
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.raw_tag_match(name).where("true /* Tag#update_category_post_counts */").find_each do |post|
|
||||||
|
|||||||
Reference in New Issue
Block a user