disable Tag.find_or_create_by_name for single tag queries with no matching tag record
This commit is contained in:
@@ -318,8 +318,8 @@ class Post < ActiveRecord::Base
|
|||||||
increment_tags = tag_array - tag_array_was
|
increment_tags = tag_array - tag_array_was
|
||||||
execute_sql("UPDATE tags SET post_count = post_count - 1 WHERE name IN (?)", decrement_tags) if decrement_tags.any?
|
execute_sql("UPDATE tags SET post_count = post_count - 1 WHERE name IN (?)", decrement_tags) if decrement_tags.any?
|
||||||
execute_sql("UPDATE tags SET post_count = post_count + 1 WHERE name IN (?)", increment_tags) if increment_tags.any?
|
execute_sql("UPDATE tags SET post_count = post_count + 1 WHERE name IN (?)", increment_tags) if increment_tags.any?
|
||||||
Post.expire_cache_for_all(decrement_tags)
|
Post.expire_cache_for_all(decrement_tags) if decrement_tags.any?
|
||||||
Post.expire_cache_for_all(increment_tags)
|
Post.expire_cache_for_all(increment_tags) if increment_tags.any?
|
||||||
Post.expire_cache_for_all([""]) if new_record? || id <= 100_000
|
Post.expire_cache_for_all([""]) if new_record? || id <= 100_000
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ module PostSetPresenters
|
|||||||
if tag
|
if tag
|
||||||
tag.related_tag_array.map(&:first)
|
tag.related_tag_array.map(&:first)
|
||||||
else
|
else
|
||||||
tag = Tag.find_or_create_by_name(post_set.tag_string)
|
[]
|
||||||
tag.related_tag_array.map(&:first)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user