From 8754e160b00d89557259d535f73ec80860173300 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Thu, 19 Mar 2026 08:36:15 -0700 Subject: [PATCH] Fix Album Completeness job scanning no albums due to wrong HAVING filter The SQL HAVING clause filtered on local track count instead of expected track count, excluding albums with fewer than 3 local tracks from the scan entirely. Now fetches all Spotify-matched albums and filters by expected track count in the loop. --- core/repair_jobs/album_completeness.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/repair_jobs/album_completeness.py b/core/repair_jobs/album_completeness.py index 05f4af79..592300fa 100644 --- a/core/repair_jobs/album_completeness.py +++ b/core/repair_jobs/album_completeness.py @@ -36,7 +36,7 @@ class AlbumCompletenessJob(RepairJob): settings = self._get_settings(context) min_tracks = settings.get('min_tracks_for_check', 3) - # Fetch albums with spotify_album_id that have enough tracks to check + # Fetch all albums with a spotify_album_id — filter by expected track count in the loop albums = [] conn = None try: @@ -50,8 +50,7 @@ class AlbumCompletenessJob(RepairJob): LEFT JOIN tracks t ON t.album_id = al.id WHERE al.spotify_album_id IS NOT NULL AND al.spotify_album_id != '' GROUP BY al.id - HAVING actual_count >= ? - """, (min_tracks,)) + """) albums = cursor.fetchall() except Exception as e: logger.error("Error fetching albums: %s", e, exc_info=True) @@ -98,6 +97,13 @@ class AlbumCompletenessJob(RepairJob): except Exception: pass + # Skip singles/EPs based on expected track count (not local count) + if expected_total and expected_total < min_tracks: + result.skipped += 1 + if context.update_progress and (i + 1) % 5 == 0: + context.update_progress(i + 1, total) + continue + if not expected_total or actual_count >= expected_total: result.skipped += 1 if context.update_progress and (i + 1) % 5 == 0: