AO3-3601 Fix pseud bookmark reindex#5734
Open
pmonfort wants to merge 3 commits intootwcode:masterfrom
Open
Conversation
brianjaustin
requested changes
Apr 18, 2026
Comment on lines
+402
to
+404
| bookmark_ids = Bookmark.where(pseud_id: id).ids | ||
| Bookmark.where(pseud_id: id).update_all(pseud_id: user.default_pseud.id) | ||
| IndexQueue.enqueue_ids(Bookmark, bookmark_ids, :main) if bookmark_ids.present? |
Member
There was a problem hiding this comment.
For consistency, could you create a scope to be used by both queries? I'm thinking along the lines of
Suggested change
| bookmark_ids = Bookmark.where(pseud_id: id).ids | |
| Bookmark.where(pseud_id: id).update_all(pseud_id: user.default_pseud.id) | |
| IndexQueue.enqueue_ids(Bookmark, bookmark_ids, :main) if bookmark_ids.present? | |
| bookmarks = Bookmark.where(pseud_id: id) | |
| bookmarks.update_all(pseud_id: user.default_pseud.id) | |
| IndexQueue.enqueue_ids(Bookmark, bookmarks.ids, :main) if bookmark_ids.present? |
Contributor
Author
There was a problem hiding this comment.
Sure, makes sense! 👍
| let(:pseud) { create(:pseud, user: user) } | ||
| let(:default_pseud) { user.default_pseud } | ||
|
|
||
| let!(:bookmarks) { Array.new(2) { create(:bookmark, pseud: pseud) } } |
Member
There was a problem hiding this comment.
(https://thoughtbot.github.io/factory_bot/building-or-creating-multiple-records/summary.html)
Suggested change
| let!(:bookmarks) { Array.new(2) { create(:bookmark, pseud: pseud) } } | |
| let!(:bookmarks) { create_list(:bookmark, 2, pseud: pseud) } |
Contributor
Author
|
@brianjaustin Thanks for your review! I've updated the code with both suggestions. Let me know how it looks. |
brianjaustin
approved these changes
Apr 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-3601
Purpose
When a pseud is deleted and its bookmarks are transferred to the default pseud,
Pseud#change_bookmarks_ownershipusesupdate_allto reassign the bookmarks.Since
update_allskips ActiveRecord callbacks, the bookmarks are never reindexed in Elasticsearch, so they don't appear on the default pseud's bookmark page.This PR enqueues the transferred bookmark IDs for reindexing after the
update_all, and modernizes the raw SQL strings to use hash conditions.Testing Instructions
Credit
Pablo Monfort (he/him)