fix: clamp negative alreadyOwned, map deezer track_id_col in seasonal endpoints

- Clamp alreadyOwned to Math.max(0, ...) in batch completion display
  to avoid showing negative owned count
- Map active_source deezer to deezer_track_id in both seasonal
  playlist endpoints (current-playlist and curated), consistent
  with core/seasonal_discovery.py logic
This commit is contained in:
JohnBaumb 2026-04-27 09:50:22 -07:00
parent 5609efa1e9
commit 20cad61e4f
2 changed files with 15 additions and 8 deletions

View file

@ -44407,9 +44407,13 @@ def get_current_seasonal_playlist():
return jsonify({"success": True, "tracks": []})
# itunes stores IDs in itunes_track_id; all other sources
# (spotify, deezer, discogs, hydrabase, etc.) use spotify_track_id
# as the generic ID column.
track_id_col = 'itunes_track_id' if active_source == 'itunes' else 'spotify_track_id'
# Each source stores IDs in its own column
if active_source == 'itunes':
track_id_col = 'itunes_track_id'
elif active_source == 'deezer':
track_id_col = 'deezer_track_id'
else:
track_id_col = 'spotify_track_id'
tracks = []
with database._get_connection() as conn:
cursor = conn.cursor()
@ -44538,10 +44542,13 @@ def get_seasonal_playlist(season_key):
if not track_ids:
return jsonify({"success": True, "tracks": []})
# itunes stores IDs in itunes_track_id; all other sources
# (spotify, deezer, discogs, hydrabase, etc.) use spotify_track_id
# as the generic ID column.
track_id_col = 'itunes_track_id' if active_source == 'itunes' else 'spotify_track_id'
# Each source stores IDs in its own column
if active_source == 'itunes':
track_id_col = 'itunes_track_id'
elif active_source == 'deezer':
track_id_col = 'deezer_track_id'
else:
track_id_col = 'spotify_track_id'
# Fetch track details from seasonal tracks or discovery pool (filtered by source)
tracks = []

View file

@ -2515,7 +2515,7 @@ function _adlRenderBatchPanel() {
if (batch.active > 0) phaseIcon = '<span class="adl-spinner" style="margin-right:4px"></span>';
} else if (batch.phase === 'complete') {
const analysisTotal = batch.analysis_total || 0;
const alreadyOwned = analysisTotal > 0 ? analysisTotal - total : 0;
const alreadyOwned = analysisTotal > 0 ? Math.max(0, analysisTotal - total) : 0;
let parts = [`${batch.completed} downloaded`];
if (alreadyOwned > 0) parts.push(`${alreadyOwned} owned`);
if (batch.failed > 0) parts.push(`${batch.failed} failed`);