Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: align Spotify import dedupeKey with live sync key format (#10107)
Adam Eivycb1b4b80fe41
diff --git a/server/services/spotifyImport.js b/server/services/spotifyImport.jsindex 90b185f145..d4306f88c5 100644--- a/server/services/spotifyImport.js+++ b/server/services/spotifyImport.js@@ -80,9 +80,12 @@ export function spotifyRecordToCandidate(record) {// Legacy/local records carry no URI — fall back to artist+album+title (or the// show for episodes) so two *different* tracks that happen to share a title at// the same instant don't wrongly collapse into one play.- const identity = uri+ // Key layout `spotify:<playedAt>:<bareId>` mirrors live sync (spotifySync.js)+ // so an imported play collides with the same play ingested live.+ const bareId = uri && /^spotify:(?:track|episode):([A-Za-z0-9]+)$/.exec(uri)?.[1];+ const identity = bareId || uri|| [artist, isEpisode ? showName : album, title].filter(Boolean).join('|');- const dedupeKey = `spotify:${identity}:${happenedAt}`;+ const dedupeKey = `spotify:${happenedAt}:${identity}`;const summaryParts = isEpisode? [showName].filter(Boolean)diff --git a/server/services/spotifyImport.test.js b/server/services/spotifyImport.test.jsindex daebe79c62..2e373feb64 100644--- a/server/services/spotifyImport.test.js+++ b/server/services/spotifyImport.test.js@@ -93,7 +93,14 @@ describe('spotifyRecordToCandidate', () => {const c1 = spotifyRecordToCandidate(extendedRecord);const c2 = spotifyRecordToCandidate({ ...extendedRecord });expect(c1.dedupeKey).toBe(c2.dedupeKey);- expect(c1.dedupeKey).toBe('spotify:spotify:track:2gjHtqrEnMBmD3lBWJUp2P:2023-05-01T18:30:00.000Z');+ expect(c1.dedupeKey).toBe('spotify:2023-05-01T18:30:00.000Z:2gjHtqrEnMBmD3lBWJUp2P');+ });++ it('keys URI records as spotify:<playedAt>:<bareId>, matching live sync', () => {+ const c = spotifyRecordToCandidate(extendedRecord);+ const [, playedAt, id] = /^spotify:(.+Z):(\w+)$/.exec(c.dedupeKey);+ expect(playedAt).toBe(c.happenedAt);+ expect(id).toBe('2gjHtqrEnMBmD3lBWJUp2P');});it('gives URI-less records an artist+album+title fallback identity (no title-only collapse)', () => {