Add non-blocking duplicate check when adding a record - #46
Merged
Conversation
Reuses the existing search service's exact_match lookup (already built for exactly this - store.find_by_artist_album's docstring says "used to flag possible duplicates while shopping" - but was never wired up on the card side). Checks fire on Discogs-result selection (immediate) and while manually typing artist/album (debounced 500ms, matching the existing Discogs-search debounce), guarded against out-of-order responses via a request token, and only in the Add Record flow - editing an existing record doesn't check against itself. Shows a neutral, non-blocking notice - it never disables Add to Collection - distinguishing an existing Collection match from an existing Wish List match. For the Wish List case, adds a "Move to Collection" action that calls update_record on the existing record (clearing is_next_buy too, since that flag only makes sense for wishlist items) instead of creating a duplicate entry - reusing the existing _saveRecord path, so it inherits the already-fixed sensor-refresh behavior for free. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
The backend groundwork for this already existed and was clearly built for it, just never wired up:
store.find_by_artist_album()'s own docstring says "used to flag possible duplicates while shopping", and thesearchservice already returns anexact_matchfield when queried with an"Artist - Album"string. No backend changes needed._saveRecordpath (and explicitly clearingis_next_buy, since that flag only makes sense for wishlist items), so it inherits the already-fixed sensor-refresh behavior for free.Test plan
store.find_by_artist_album()directly: case-insensitive matching, correctly distinguishes a Wish List match from a Collection match, no false positives.query.split(" - ", 1)) the card's"<artist> - <album>"query format relies on.handle_update_record(used by the "Move to Collection" action) still calls_refresh_sensorsonmain.🤖 Generated with Claude Code