fixes #2269
This commit is contained in:
@@ -437,12 +437,10 @@ class Post < ActiveRecord::Base
|
|||||||
decrement_tags = tag_array_was - tag_array
|
decrement_tags = tag_array_was - tag_array
|
||||||
increment_tags = tag_array - tag_array_was
|
increment_tags = tag_array - tag_array_was
|
||||||
if increment_tags.any?
|
if increment_tags.any?
|
||||||
Tag.where(:name => increment_tags).update_all("post_count = post_count + 1")
|
Tag.delay(:queue => "default").increment_post_counts(increment_tags)
|
||||||
Post.expire_cache_for_all(increment_tags)
|
|
||||||
end
|
end
|
||||||
if decrement_tags.any?
|
if decrement_tags.any?
|
||||||
Tag.where(:name => decrement_tags).update_all("post_count = post_count - 1")
|
Tag.delay(:queue => "default").decrement_post_counts(decrement_tags)
|
||||||
Post.expire_cache_for_all(decrement_tags)
|
|
||||||
end
|
end
|
||||||
Post.expire_cache_for_all([""]) if new_record? || id <= 100_000
|
Post.expire_cache_for_all([""]) if new_record? || id <= 100_000
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -47,6 +47,16 @@ class Tag < ActiveRecord::Base
|
|||||||
select("post_count").order("post_count DESC").first.post_count
|
select("post_count").order("post_count DESC").first.post_count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def increment_post_counts(tag_names)
|
||||||
|
Tag.where(:name => tag_names).update_all("post_count = post_count + 1")
|
||||||
|
Post.expire_cache_for_all(tag_names)
|
||||||
|
end
|
||||||
|
|
||||||
|
def decrement_post_counts(tag_names)
|
||||||
|
Tag.where(:name => tag_names).update_all("post_count = post_count - 1")
|
||||||
|
Post.expire_cache_for_all(tag_names)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def real_post_count
|
def real_post_count
|
||||||
|
|||||||
Reference in New Issue
Block a user