""" This file contains queries that are used to fetch information about tracks. """ """ QUERY_TRACK_TUID_BACKFILL returns tuids for processing the fingerprint backfill. The date range will be from midnight of 'daterange_start_days' days ago to exactly daterange_end_seconds ago. For example if now='2016-01-11 15:00:50'; daterange_start_days=5; and daterange_end_seconds=3600; this query will search the last_updated time range of 2016-01-06 00:00:00 to 2016-01-11 14:00:50 inclusive. """ QUERY_TRACK_TUID_BACKFILL = """ SELECT t.id AS tuid FROM art_relations.track t JOIN art_relations.releases r ON r.release_id = t.release_id WHERE t.track_type = 'music' AND r.release_status = 'in_content' AND t.last_updated BETWEEN Date_sub(Curdate(), INTERVAL :daterange_start_days day) AND Date_sub(Now(), INTERVAL :daterange_end_seconds second) """ """ QUERY_TRACK_TUID_SWEEPER returns tuids for sweeper processing. For sweeper, we are not restricting release_status to a particular value. The date range will be from midnight of 'daterange_start_days' days ago to exactly daterange_end_seconds ago. For example if now='2016-01-11 15:00:50'; daterange_start_days=5; and daterange_end_seconds=3600; this query will search the last_updated time range of 2016-01-06 00:00:00 to 2016-01-11 14:00:50 inclusive. """ QUERY_TRACK_TUID_SWEEPER = """ SELECT t.id AS tuid FROM art_relations.track t WHERE t.track_type = 'music' AND t.last_updated BETWEEN Date_sub(Curdate(), INTERVAL :daterange_start_days day) AND Date_sub(Now(), INTERVAL :daterange_end_seconds second) """ """ QUERY_TRACK_TUID_VENDOR returns tuids for a vendor_id. This is for running a custom backill for a specific vendor """ QUERY_TRACK_TUID_VENDOR = """ SELECT t.id AS tuid FROM art_relations.track t JOIN art_relations.releases r ON r.release_id = t.release_id JOIN art_relations.artist_info ai ON ai.artist_id = r.artist_id WHERE t.track_type = 'music' AND r.release_status = 'in_content' AND t.last_updated BETWEEN Date_sub(Curdate(), INTERVAL :daterange_start_days day) AND Date_sub(Now(), INTERVAL :daterange_end_seconds second) AND ai.vendor_id = :vendor_id """ """ QUERY_TRACK_TUID_DETAILS returns the tuid-to-upc mapping for tuids in the provided list """ QUERY_TRACK_TUID_DETAILS = """ SELECT id AS tuid, upc, cd, track_id FROM track WHERE id IN( {} ) """