This commit is contained in:
albert
2013-03-09 01:56:59 -05:00
parent 6a2f69f2fc
commit 1da9e24bd0
3 changed files with 14 additions and 1 deletions

View File

@@ -87,6 +87,7 @@ class Tag < ActiveRecord::Base
def update_category_cache_for_all(force = false)
if category_changed? || force
update_category_cache
update_category_post_counts if category_changed?
Danbooru.config.other_server_hosts.each do |host|
delay(:queue => host).update_category_cache
@@ -94,6 +95,12 @@ class Tag < ActiveRecord::Base
end
end
def update_category_post_counts
old_field = "tag_count_#{Danbooru.config.reverse_tag_category_mapping[category_was]}".downcase
new_field = "tag_count_#{category_name}".downcase
Post.raw_tag_match(name).update_all("#{old_field} = #{old_field} - 1, #{new_field} = #{new_field} + 1")
end
def update_category_cache
Cache.put("tc:#{Cache.sanitize(name)}", category, 1.hour)
end