-- @query thumbnail_resolve_rb
-- @db thumbnailCache 9.0
-- @param fs_ids  TEXT
-- @param liu_ids TEXT
SELECT
    lower(hex(tm.fileSystemId)) AS fileSystemId,
    NULL                        AS listItemUniqueId,
    tm.id,
    tm.boxSize
FROM thumbnailCache.thumbnail_metadata tm
WHERE tm.fileSystemId IS NOT NULL
  AND lower(hex(tm.fileSystemId)) IN (SELECT lower(value) FROM json_each(?fs_ids))
UNION ALL
SELECT
    NULL                        AS fileSystemId,
    tm.listItemUniqueId,
    tm.id,
    tm.boxSize
FROM thumbnailCache.thumbnail_metadata tm
WHERE tm.listItemUniqueId IS NOT NULL
  AND tm.listItemUniqueId IN (SELECT value FROM json_each(?liu_ids));
