mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 14:03:22 +08:00
FIX: tag topic counts wrong after adding synonyms
After adding a tag as a synonym of another tag, both tags will have the wrong topic counts. It's corrected within 12 hours by the EnsureDbConsistency job. This fix ensures the topic counts are updated much sooner.
This commit is contained in:
parent
fadb2b7157
commit
c31039d51f
|
@ -424,6 +424,9 @@ module DiscourseTagging
|
|||
end
|
||||
successful = existing.select { |t| !t.errors.present? }
|
||||
TopicTag.where(tag_id: successful.map(&:id)).update_all(tag_id: target_tag.id)
|
||||
Scheduler::Defer.later "Update tag topic counts" do
|
||||
Tag.ensure_consistency!
|
||||
end
|
||||
(existing - successful).presence || true
|
||||
end
|
||||
|
||||
|
|
|
@ -568,6 +568,8 @@ describe DiscourseTagging do
|
|||
topic = Fabricate(:topic, tags: [tag2])
|
||||
expect(DiscourseTagging.add_or_create_synonyms_by_name(tag1, [tag2.name])).to eq(true)
|
||||
expect_same_tag_names(topic.reload.tags, [tag1])
|
||||
expect(tag1.reload.topic_count).to eq(1)
|
||||
expect(tag2.reload.topic_count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user