mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: delete synonyms in topics if target tag is already added.
Currently, while adding a synonym tag if both target and synonym tags are already available in a topic then it's returning an error.
This commit is contained in:
@@ -423,7 +423,9 @@ module DiscourseTagging
|
||||
target_tag.synonyms << Tag.create(name: name)
|
||||
end
|
||||
successful = existing.select { |t| !t.errors.present? }
|
||||
TopicTag.where(tag_id: successful.map(&:id)).update_all(tag_id: target_tag.id)
|
||||
synonyms_ids = successful.map(&:id)
|
||||
TopicTag.where(topic_id: target_tag.topics.with_deleted, tag_id: synonyms_ids).delete_all
|
||||
TopicTag.where(tag_id: synonyms_ids).update_all(tag_id: target_tag.id)
|
||||
Scheduler::Defer.later "Update tag topic counts" do
|
||||
Tag.ensure_consistency!
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user