Fix enrichment workers never showing idle/complete status

Pending count queries included NULL-ID rows that _get_next_item filters
out, so pending stayed > 0 even when no processable items remained.
Workers reported running instead of idle, UI never turned green. Added
AND id IS NOT NULL to _count_pending_items across all 9 workers to
match the _get_next_item filter.
pull/253/head
Broque Thomas 2 months ago
parent e0533215da
commit be77397132

@ -558,9 +558,9 @@ class AudioDBWorker:
cursor.execute("""
SELECT
(SELECT COUNT(*) FROM artists WHERE audiodb_match_status IS NULL) +
(SELECT COUNT(*) FROM albums WHERE audiodb_match_status IS NULL) +
(SELECT COUNT(*) FROM tracks WHERE audiodb_match_status IS NULL)
(SELECT COUNT(*) FROM artists WHERE audiodb_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM albums WHERE audiodb_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM tracks WHERE audiodb_match_status IS NULL AND id IS NOT NULL)
AS pending
""")

@ -631,9 +631,9 @@ class DeezerWorker:
cursor.execute("""
SELECT
(SELECT COUNT(*) FROM artists WHERE deezer_match_status IS NULL) +
(SELECT COUNT(*) FROM albums WHERE deezer_match_status IS NULL) +
(SELECT COUNT(*) FROM tracks WHERE deezer_match_status IS NULL)
(SELECT COUNT(*) FROM artists WHERE deezer_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM albums WHERE deezer_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM tracks WHERE deezer_match_status IS NULL AND id IS NOT NULL)
AS pending
""")

@ -464,8 +464,8 @@ class GeniusWorker:
cursor = conn.cursor()
cursor.execute("""
SELECT
(SELECT COUNT(*) FROM artists WHERE genius_match_status IS NULL) +
(SELECT COUNT(*) FROM tracks WHERE genius_match_status IS NULL)
(SELECT COUNT(*) FROM artists WHERE genius_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM tracks WHERE genius_match_status IS NULL AND id IS NOT NULL)
AS pending
""")
row = cursor.fetchone()

@ -847,9 +847,9 @@ class iTunesWorker:
cursor = conn.cursor()
cursor.execute("""
SELECT
(SELECT COUNT(*) FROM artists WHERE itunes_match_status IS NULL) +
(SELECT COUNT(*) FROM albums WHERE itunes_match_status IS NULL) +
(SELECT COUNT(*) FROM tracks WHERE itunes_match_status IS NULL)
(SELECT COUNT(*) FROM artists WHERE itunes_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM albums WHERE itunes_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM tracks WHERE itunes_match_status IS NULL AND id IS NOT NULL)
AS pending
""")
row = cursor.fetchone()

@ -572,9 +572,9 @@ class LastFMWorker:
cursor = conn.cursor()
cursor.execute("""
SELECT
(SELECT COUNT(*) FROM artists WHERE lastfm_match_status IS NULL) +
(SELECT COUNT(*) FROM albums WHERE lastfm_match_status IS NULL) +
(SELECT COUNT(*) FROM tracks WHERE lastfm_match_status IS NULL)
(SELECT COUNT(*) FROM artists WHERE lastfm_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM albums WHERE lastfm_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM tracks WHERE lastfm_match_status IS NULL AND id IS NOT NULL)
AS pending
""")
row = cursor.fetchone()

@ -323,9 +323,9 @@ class MusicBrainzWorker:
# Count unattempted items
cursor.execute("""
SELECT
(SELECT COUNT(*) FROM artists WHERE musicbrainz_match_status IS NULL) +
(SELECT COUNT(*) FROM albums WHERE musicbrainz_match_status IS NULL) +
(SELECT COUNT(*) FROM tracks WHERE musicbrainz_match_status IS NULL)
(SELECT COUNT(*) FROM artists WHERE musicbrainz_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM albums WHERE musicbrainz_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM tracks WHERE musicbrainz_match_status IS NULL AND id IS NOT NULL)
AS pending
""")

@ -754,9 +754,9 @@ class QobuzWorker:
cursor.execute("""
SELECT
(SELECT COUNT(*) FROM artists WHERE qobuz_match_status IS NULL) +
(SELECT COUNT(*) FROM albums WHERE qobuz_match_status IS NULL) +
(SELECT COUNT(*) FROM tracks WHERE qobuz_match_status IS NULL)
(SELECT COUNT(*) FROM artists WHERE qobuz_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM albums WHERE qobuz_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM tracks WHERE qobuz_match_status IS NULL AND id IS NOT NULL)
AS pending
""")

@ -892,9 +892,9 @@ class SpotifyWorker:
cursor = conn.cursor()
cursor.execute("""
SELECT
(SELECT COUNT(*) FROM artists WHERE spotify_match_status IS NULL) +
(SELECT COUNT(*) FROM albums WHERE spotify_match_status IS NULL) +
(SELECT COUNT(*) FROM tracks WHERE spotify_match_status IS NULL)
(SELECT COUNT(*) FROM artists WHERE spotify_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM albums WHERE spotify_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM tracks WHERE spotify_match_status IS NULL AND id IS NOT NULL)
AS pending
""")
row = cursor.fetchone()

@ -777,9 +777,9 @@ class TidalWorker:
cursor.execute("""
SELECT
(SELECT COUNT(*) FROM artists WHERE tidal_match_status IS NULL) +
(SELECT COUNT(*) FROM albums WHERE tidal_match_status IS NULL) +
(SELECT COUNT(*) FROM tracks WHERE tidal_match_status IS NULL)
(SELECT COUNT(*) FROM artists WHERE tidal_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM albums WHERE tidal_match_status IS NULL AND id IS NOT NULL) +
(SELECT COUNT(*) FROM tracks WHERE tidal_match_status IS NULL AND id IS NOT NULL)
AS pending
""")

Loading…
Cancel
Save