-- @query thumbnails_count_favorites
-- @db media 11.0
SELECT COUNT(*) AS cnt FROM media_properties mp
JOIN media_libraries drive ON drive.driveId = mp.driveId
JOIN media_favorites mf ON mf.listItemUniqueId = mp.listItemUniqueId
  AND mf.listId = drive.listId AND mf.siteId = drive.siteId
WHERE mp.takenDateTime IS NOT NULL AND mp.takenDateTime != ''
  AND mp.isTombstoned = 0
