AO3-7294 Maintenance task to reset bookmark-only tags #5580
+83
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
as the first thing in your pull request title (e.g.
AO3-1234 Fix thing)until they are reviewed and merged before creating new pull requests.
Issue
https://otwarchive.atlassian.net/browse/AO3-7294
Purpose
This PR addresses the accumulation of "bookmark-only" tags in wrangler bins. Sometimes, tags that are only used on bookmarks (and have zero works) get assigned a specific type (like Character or Relationship) or get attached to a Fandom. This clutters the wrangling interface with tags that shouldn't be wrangled yet.
Changes implemented:
1. New Rake Task (
tags:reset_bookmark_only):taggings_count_cache: 0).typeother than'Tag'(Unsorted) OR if they have parent associations (common_taggings).typeto'Tag'(Unsorted) and removes all parent associations.2. Scheduled Maintenance:
config/schedule.rbto run quarterly, ensuring the bins stay clean automatically over time.Technical Notes:
find_each(batch size 1000) to avoid memory spikes when processing large numbers of tags.delete_allfor associations andupdate_columnsfor the tag itself. This intentionally bypasses ActiveRecord callbacks to prevent triggering expensive Elasticsearch/Redis re-indexing for every single tag reset during bulk maintenance.spec/lib/tasks/reset_bookmark_tags_spec.rb) covering scenarios for incorrect tags, legitimate work tags, and canonical tags.Testing Instructions
Prerequisites:
You will need access to the Rails console (bundle exec rails c) or the ability to run Rake tasks.
Steps to Verify:
1. Create a "Dirty" Tag (The Target):
2. Create a "Control" Tag (The Innocent):
3. Run the Task:
bundle exec rake tags:reset_bookmark_only4. Verify Results:
Credit
Snoopynha
(She/Her)
*On Jira for assign the issues: Camilly Vitória Barbosa dos Santos