Fix artist info modal failing on watchlist map nodes with NULL IDs

Watchlist map nodes used w.get('key', '') which returns None when the
DB column is NULL (key exists with None value). None serialized to JSON
null, which is falsy in JS, causing 'No source ID' throw for every
artist click.

- Changed to `w.get('key') or ''` for all ID fields (coerces None→'')
- Added discogs_id to watchlist nodes (was missing entirely)
- Removed hard throw when no source ID — falls back to name-based lookup
- Added console.error logging for future diagnosis
pull/253/head
Broque Thomas 1 month ago
parent d34924e238
commit 32cc7cbd5e

@ -41291,9 +41291,10 @@ def get_artist_map_data():
'image_url': img,
'type': 'watchlist',
'genres': [],
'spotify_id': w.get('spotify_artist_id', ''),
'itunes_id': w.get('itunes_artist_id', ''),
'deezer_id': w.get('deezer_artist_id', ''),
'spotify_id': w.get('spotify_artist_id') or '',
'itunes_id': w.get('itunes_artist_id') or '',
'deezer_id': w.get('deezer_artist_id') or '',
'discogs_id': w.get('discogs_artist_id') or '',
'source_db_id': str(w['id']),
})
@ -41333,9 +41334,9 @@ def get_artist_map_data():
'image_url': img,
'type': 'similar',
'genres': genres,
'spotify_id': r.get('similar_artist_spotify_id', ''),
'itunes_id': r.get('similar_artist_itunes_id', ''),
'deezer_id': r.get('similar_artist_deezer_id', ''),
'spotify_id': r.get('similar_artist_spotify_id') or '',
'itunes_id': r.get('similar_artist_itunes_id') or '',
'deezer_id': r.get('similar_artist_deezer_id') or '',
'rank': r.get('similarity_rank', 5),
'occurrence': r.get('occurrence_count', 1),
'popularity': r.get('popularity', 0),

@ -55225,10 +55225,10 @@ async function openYourArtistInfoModal(poolId) {
// Fetch enrichment data (with timeout)
try {
if (!artistId) throw new Error('No source ID');
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 8000);
const resp = await fetch(`/api/discover/your-artists/info/${artistId}?name=${encodeURIComponent(artistName)}`, { signal: controller.signal });
const lookupId = artistId || encodeURIComponent(artistName);
const resp = await fetch(`/api/discover/your-artists/info/${lookupId}?name=${encodeURIComponent(artistName)}`, { signal: controller.signal });
clearTimeout(timeout);
const artist = resp.ok ? await resp.json() : {};
const bodyEl = document.getElementById('ya-info-body');
@ -55320,6 +55320,7 @@ async function openYourArtistInfoModal(poolId) {
`;
}
} catch (err) {
console.error('[Artist Info] Error loading artist info:', err);
const bodyEl = document.getElementById('ya-info-body');
if (bodyEl) bodyEl.innerHTML = `<div class="ya-info-empty">Could not load artist info</div>`;
}

Loading…
Cancel
Save