openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Allow reversion of a single work or author after bulk merge

Open seabelis opened this issue 1 year ago • 3 comments

Feature Request

Problem / Opportunity

Sometimes incorrect records are merged. Usually this is with a bulk merge where all or most other merged records were merged correctly. Having the option for admins to select a single merged record from a bulk merge would be useful. Example, https://openlibrary.org/recentchanges/2025/07/18/merge-works/151730566, one title was incorrectly merged with a merge of six works. If I revert this, all will be reversed. I only want to revert the one, along with associated editions that were initially associated with that work.

Manually identifying and reverting records is time consuming. Sometimes this involves hundreds or thousands of records.

Success is when a single merge can be "cherry picked" from a bulk merge to be reverted.

Proposal

Breakdown

Related files

Refer to this map of common Endpoints: *

Requirements Checklist

Checklist of requirements that need to be satisfied in order for this issue to be closed:

  • [ ]

Stakeholders


Instructions for Contributors

seabelis avatar Oct 08 '25 10:10 seabelis

On an Edition or Author history page, there might be a button to undo merge which brings you to a page that shows all the records that were combined during that merge and gives you the ability to select any one of them (at a time) and "undo".

For now it's an intentional design choice to only revert one merge item (Work or Author) at a time to increase chances of applying cleanly.

mekarpeles avatar Oct 13 '25 20:10 mekarpeles

Hi @mekarpeles and @jimchamp ,

Thanks for the UX direction — the one-at-a-time restriction makes a lot of sense for safety!

I've been digging into BasicMergeEngine and the versioning system, and I'd love to work on at implementing this selective revert.

Before I open a PR or go too deep into a prototype, do you have any preferred existing helpers/utilities for:

  1. Safely stripping a single duplicate's data back out of the master record (given no field provenance)?

  2. Re-pointing external references (e.g., editions/works) away from the master and back to the restored /type/redirect duplicate?

  3. Triggering a Solr reindex afterward (post-changeset save)?

Any pointers on those three operations or related files/utils.....would be appreciated to ensure my approach respects Infogami data integrity and team patterns!

bhardwajparth51 avatar Feb 21 '26 18:02 bhardwajparth51

Hi @mekarpeles,

Following your idea, I’ve implemented a prototype for selective undo, but I would like to get some confirmation on the approach. Here’s what I have so far:

Backend

  • Added a new changeset type undo-single-duplicate(only one item is reverted at one undo)

  • Implemented a POST handler for single-item revert

  • Each undo request generates a corresponding changeset, and a link provided to view the changelog

Frontend

The current merge view renders all non-primary items in a single row, which doesn’t leave room for per-item actions.

Previous layout:

Image

New layout:

Each merged work/author will be displayed on its own row, with an "Undo" button at right of each row. Besides, a “Related records” toggle is also added to show associated records of merge items. The updated page is shown below: Image Image


Button effect:

When Undo button is clicked, our backend will trigger the undo-single-duplicate action and undo merge for the clicked merge item. After that, the manager can click the link provided and view changelog of the single reversion. Image Image The single Undo button will be disabled if a bulk undo has already been applied. However, the changelog link will still last at the page if one or multiple single undoese have been done before. Image


The implementation is mostly complete and currently under testing. Likely I'll open a PR shortly once everything is verified.

Cyberfrogqwq avatar Mar 18 '26 08:03 Cyberfrogqwq