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: