Draft
Add confirmed player duplicates tracking and admin API#586
Conversation
…eduplication Agent-Logs-Url: https://github.com/benckx/elephantchess/sessions/7ab5d051-4357-4383-a36a-62fb93e12563 Co-authored-by: benckx <8626080+benckx@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add logic to process database player duplicates
Add confirmed player duplicates tracking and admin API
May 13, 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.
Player duplicates were only detected heuristically via name variations at query time with no way to persist confirmed relationships. This adds a formal DB entity to record confirmed duplicates and uses them in game stats aggregation.
Schema
New table
reference_player_duplicate(player_id PK → reference_player, is_duplicate_of → reference_player)whereplayer_idis the duplicate andis_duplicate_ofis the canonical entry.DAO (
ReferencePlayerDaoService)savePlayerDuplicate— upsert (conflict-update) a duplicate relationshipfindConfirmedDuplicatesOf— all duplicates for a canonical playerfindCanonicalPlayerFor— canonical player for a given duplicatedeletePlayerDuplicate/listAllPlayerDuplicatesService layer (
DatabaseService)fetchPlayerGameStatsnow checks confirmed DB duplicates first; falls back to name-based heuristics only when none are registered.Admin API
New endpoints at
/api/admin/analytics/player-duplicates:GET— list all confirmed duplicates with canonical namesPOST— register a duplicate (RegisterPlayerDuplicateRequest: {playerId, isNewDuplicateOf})DELETE— remove a relationship (DeletePlayerDuplicateRequest: {playerId})registerPlayerDuplicatevalidates against self-references and cycles (canonical player must not itself be a duplicate; duplicate must not already serve as canonical for others).