Bulk tagged topics, then moved topics into another category, but the category tag selector doesn't show tags

It worked, but in this category, the tag selector is empty:

The tag does appear with the search:

image

But I would like the tag to appear by default among others in this list, like here on meta:

image

Here’s exactly the code I used:

rake tags:bulk_tag_category["électricité",33]
tag = Tag.find_by_name("électricité")
cat_to = Category.find_by_slug('mecanique')
Topic.joins(:topic_tags).where("topic_tags.tag_id = ?", tag.id).update_all(category_id: cat_to.id)
Category.update_stats

Is there any Sidekiq task or another thing (a rails command to update some stats maybe?) to do in order to have the category selector working?

I’m looking at the database content with #data-explorer.

The category_tags table is kinda empty, except for two tags (id 1 and 2) from another category which has nothing to do with my issue.

My other tag “électricité” (with 2 other tags), which belongs to the category “Mécanique”, should be present here I believe.

In the category_tag_stats, there are also issues:

The categories id 33, 32 and 34 (which here wrongly link to /t/33, t/32 and /t/34 instead of categories, which seems a data explorer bug because the query output seems alright) don’t exist anymore: I deleted them after moving all their topics in another category.

For example, the category id 33 was the category where I bulk tagged all topics as “électricité”.
Then I moved all these topics to the category id 83.

So the data in these tables are wrong, despite the fact I followed recommended commands to bulk tag and move topics.

Do these commands miss something to update these tables accordingly?

[removed a workaround I thought worked at first, but which didn’t ; so, I’m still having this issue]


I tried moving the topics using the rake task

rake categories:move_topics[15,6]

instead of the ruby script to move tagged topics to another category, but the issue is the same: the category_tags and category_tag_stats tables still seem not to be properly updated when moving topics.

1 Like

Has it fixed itself over time out of curiosity? There is a database consistency job that should run every 12 hours. It covers the tags, categories, and category_tag_stats tables. It’s possible we aren’t covering a couple areas that should be checked for consistency.

If it has fixed itself and the issue is that it feels like it’s taking too long. Maybe we can call the relevant consistency methods in the rake task/add them to any relevant scripts in the bulk operations topic.

I already triggered the sidekiq job several days ago but it didn’t fix the issue, and to this day, my tag selector is still empty:


Edit: I confirm the issue didn’t correct by itself after all this time, so the sidekiq job definitely did not fix this issue.

2 Likes