Skip to content

Add non-blocking duplicate check when adding a record - #46

Merged
snowmonkeylab merged 1 commit into
mainfrom
duplicate-check
Aug 30, 2026
Merged

Add non-blocking duplicate check when adding a record#46
snowmonkeylab merged 1 commit into
mainfrom
duplicate-check

Conversation

@snowmonkeylab

Copy link
Copy Markdown
Owner

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 the search service already returns an exact_match field when queried with an "Artist - Album" string. No backend changes needed.

  • Checks fire when selecting a Discogs search result (immediate) and while manually typing artist/album (debounced 500ms, matching the existing Discogs-search debounce pattern), guarded against out-of-order async responses via a request token.
  • Add-flow only — editing an existing record doesn't check against itself.
  • Shows a neutral, non-blocking notice under the Artist/Album fields — never disables "Add to Collection".
  • Distinguishes an existing Collection match ("You already have this in your Collection.") from a Wish List match ("This is in your Wish List."). For the Wish List case, adds a "Move to Collection" action that updates the existing record instead of creating a duplicate — reusing the existing _saveRecord path (and explicitly clearing is_next_buy, since that flag only makes sense for wishlist items), so it inherits the already-fixed sensor-refresh behavior for free.

Test plan

  • Verified store.find_by_artist_album() directly: case-insensitive matching, correctly distinguishes a Wish List match from a Collection match, no false positives.
  • Confirmed the backend query-splitting logic (query.split(" - ", 1)) the card's "<artist> - <album>" query format relies on.
  • Confirmed handle_update_record (used by the "Move to Collection" action) still calls _refresh_sensors on main.
  • Deployed to a local Docker HA test instance; clean restart with no tracebacks.
  • Click through in the browser: Discogs-selection trigger, manual-typing trigger, Collection-match wording, Wish-List-match wording + Move to Collection action, sensor counts updating after the move.

🤖 Generated with Claude Code

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>
@snowmonkeylab
snowmonkeylab merged commit 76e19d3 into main Aug 30, 2026
4 checks passed
@snowmonkeylab
snowmonkeylab deleted the duplicate-check branch August 30, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant