Update tag_implication#update_posts_for_create
* Remove "_for_create" from name, now that update_posts_for_destroy is removed * Use raw_tag_match instead of tag_match to avoid inconsistencies * Just append the implicated tags to the end of the tag string, rather than using regex
This commit is contained in:
@@ -110,7 +110,7 @@ class TagImplication < ActiveRecord::Base
|
|||||||
|
|
||||||
def process!
|
def process!
|
||||||
update_column(:status, "processing")
|
update_column(:status, "processing")
|
||||||
update_posts_for_create
|
update_posts
|
||||||
update_column(:status, "active")
|
update_column(:status, "active")
|
||||||
update_descendant_names_for_parent
|
update_descendant_names_for_parent
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@@ -125,10 +125,9 @@ class TagImplication < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_posts_for_create
|
def update_posts
|
||||||
Post.tag_match("#{antecedent_name} status:any").find_each do |post|
|
Post.raw_tag_match(antecedent_name).find_each do |post|
|
||||||
escaped_antecedent_name = Regexp.escape(antecedent_name)
|
fixed_tags = "#{post.tag_string} #{descendant_names}".strip
|
||||||
fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{antecedent_name} #{descendant_names} ").strip
|
|
||||||
CurrentUser.scoped(creator, creator_ip_addr) do
|
CurrentUser.scoped(creator, creator_ip_addr) do
|
||||||
post.update_attributes(
|
post.update_attributes(
|
||||||
:tag_string => fixed_tags
|
:tag_string => fixed_tags
|
||||||
|
|||||||
Reference in New Issue
Block a user