update db
This commit is contained in:
@@ -175,7 +175,7 @@ class RadarrDbClient:
|
|||||||
Returns:
|
Returns:
|
||||||
(date_iso, source_description)
|
(date_iso, source_description)
|
||||||
"""
|
"""
|
||||||
# Query for earliest import event - handle both numeric (3) and string ('downloadFolderImported') formats
|
# Query for earliest import event - PostgreSQL uses INTEGER EventType (3 = import)
|
||||||
import_query = """
|
import_query = """
|
||||||
SELECT
|
SELECT
|
||||||
h."Date" as event_date,
|
h."Date" as event_date,
|
||||||
@@ -183,12 +183,12 @@ class RadarrDbClient:
|
|||||||
h."EventType" as event_type
|
h."EventType" as event_type
|
||||||
FROM "History" h
|
FROM "History" h
|
||||||
WHERE h."MovieId" = %s
|
WHERE h."MovieId" = %s
|
||||||
AND (h."EventType" = 3 OR h."EventType" = 'downloadFolderImported' OR h."EventType" = 'movieFileImported')
|
AND h."EventType" = 3
|
||||||
ORDER BY h."Date" ASC
|
ORDER BY h."Date" ASC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Fallback: earliest grab event - handle both numeric (1) and string ('grabbed') formats
|
# Fallback: earliest grab event - PostgreSQL uses INTEGER EventType (1 = grab)
|
||||||
grab_query = """
|
grab_query = """
|
||||||
SELECT
|
SELECT
|
||||||
h."Date" as event_date,
|
h."Date" as event_date,
|
||||||
@@ -196,7 +196,7 @@ class RadarrDbClient:
|
|||||||
h."EventType" as event_type
|
h."EventType" as event_type
|
||||||
FROM "History" h
|
FROM "History" h
|
||||||
WHERE h."MovieId" = %s
|
WHERE h."MovieId" = %s
|
||||||
AND (h."EventType" = 1 OR h."EventType" = 'grabbed')
|
AND h."EventType" = 1
|
||||||
AND h."Data" IS NOT NULL
|
AND h."Data" IS NOT NULL
|
||||||
ORDER BY h."Date" ASC
|
ORDER BY h."Date" ASC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
@@ -346,8 +346,7 @@ class RadarrDbClient:
|
|||||||
MIN(h."Date") as earliest_import
|
MIN(h."Date") as earliest_import
|
||||||
FROM "Movies" m
|
FROM "Movies" m
|
||||||
JOIN "MovieMetadata" mm ON m."MovieMetadataId" = mm."Id"
|
JOIN "MovieMetadata" mm ON m."MovieMetadataId" = mm."Id"
|
||||||
LEFT JOIN "History" h ON m."Id" = h."MovieId"
|
LEFT JOIN "History" h ON m."Id" = h."MovieId" AND h."EventType" = 3
|
||||||
AND (h."EventType" = 3 OR h."EventType" = 'downloadFolderImported' OR h."EventType" = 'movieFileImported')
|
|
||||||
WHERE mm."ImdbId" IN ({placeholders})
|
WHERE mm."ImdbId" IN ({placeholders})
|
||||||
GROUP BY mm."ImdbId", m."Id"
|
GROUP BY mm."ImdbId", m."Id"
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user