mirror of
https://gitlab.com/sspaeth/cleanmedia.git
synced 2025-04-03 18:30:48 +00:00
Optimize Sanity Check SQL
Instead of SELECT COUNT(media_id) from mediaapi_thumbnail WHERE media_id NOT IN (SELECT media_id FROM mediaapi_media_repository); we do SELECT COUNT(media_id) from mediaapi_thumbnail WHERE NOT EXISTS (SELECT media_id FROM mediaapi_media_repository); Per Till's (@s7evink:matrix.org) suggestion. All credit to him
This commit is contained in:
parent
0a03429abf
commit
7a4d497353
1 changed files with 1 additions and 1 deletions
|
@ -177,7 +177,7 @@ class MediaRepository:
|
|||
def sanity_check_thumbnails(self) -> None:
|
||||
"""Warn if we have thumbnails in the db that do not refer to existing media"""
|
||||
with self.conn.cursor() as cur:
|
||||
cur.execute("SELECT COUNT(media_id) from mediaapi_thumbnail WHERE media_id NOT IN (SELECT media_id FROM mediaapi_media_repository);")
|
||||
cur.execute("SELECT COUNT(media_id) from mediaapi_thumbnail WHERE NOT EXISTS (SELECT media_id FROM mediaapi_media_repository);")
|
||||
row = cur.fetchone()
|
||||
if row is not None and row[0]:
|
||||
logging.error("You have {} thumbnails in your db that do not refer to media. This needs fixing (we don't do that)!".format(row[0]))
|
||||
|
|
Loading…
Add table
Reference in a new issue