diff --git a/quotaclimat/data_processing/mediatree/api_import.py b/quotaclimat/data_processing/mediatree/api_import.py index 8f1de148b..c962953b4 100644 --- a/quotaclimat/data_processing/mediatree/api_import.py +++ b/quotaclimat/data_processing/mediatree/api_import.py @@ -5,7 +5,7 @@ import logging import asyncio -import time +from time import sleep import sys import os from quotaclimat.utils.healthcheck_config import run_health_check_server @@ -243,8 +243,9 @@ async def main(): # Without this we have a CrashLoopBackOff (Kubernetes health error) if (os.environ.get("ENV") != "dev" and os.environ.get("ENV") != "docker"): minutes = 15 + seconds_to_minute = 60 logging.warning(f"Sleeping {minutes} before safely exiting scaleway container") - time.sleep(60 * minutes) + sleep(seconds_to_minute * minutes) res=health_check_task.cancel() logging.info("Exiting with success") diff --git a/quotaclimat/data_processing/mediatree/channel_metadata.py b/quotaclimat/data_processing/mediatree/channel_metadata.py new file mode 100644 index 000000000..9c87b9420 --- /dev/null +++ b/quotaclimat/data_processing/mediatree/channel_metadata.py @@ -0,0 +1,539 @@ +# based on Mediatree Annexe 1 : Périmètre - minutes per +duration_by_channel_day = { + "tf1": { + "monday":80, + "tuesday":80, + "wednesday":80, + "thursday":80, + "friday":80, + "saturday":80, + "sunday":80, + }, + "france2": { + "monday": 80, + "tuesday": 80, + "wednesday": 80, + "thursday": 80, + "friday": 80, + "saturday": 160, + "sunday": 80, + }, + "france3": { + "monday": 100, + "tuesday": 100, + "wednesday": 100, + "thursday": 100, + "friday": 100, + "saturday": 100, + "sunday": 100, + }, + "france5": { + "monday": 205, + "tuesday": 205, + "wednesday": 205, + "thursday": 205, + "friday": 135, + "saturday": 140, + "sunday": 60, + }, + "m6": { + "monday": 100, + "tuesday": 100, + "wednesday": 100, + "thursday": 100, + "friday": 100, + "saturday": 100, + "sunday": 225, + }, + "arte": { + "monday": 65, + "tuesday": 65, + "wednesday": 65, + "thursday": 65, + "friday": 65, + "saturday": 65, + "sunday": 20, + }, + "d8": { + "monday": 140, + "tuesday": 140, + "wednesday": 140, + "thursday": 140, + "friday": 140, + "saturday": 0, + "sunday": 0, + }, + "tmc": { + "monday": 125, + "tuesday": 125, + "wednesday": 125, + "thursday": 125, + "friday": 125, + "saturday": 0, + "sunday": 0, + }, + "bfmtv": { + "monday": 960, + "tuesday": 960, + "wednesday": 960, + "thursday": 960, + "friday": 960, + "saturday": 960, + "sunday": 960, + }, + "lci": { + "monday": 960, + "tuesday": 960, + "wednesday": 960, + "thursday": 960, + "friday": 960, + "saturday": 960, + "sunday": 960, + }, + "franceInfo": { + "monday": 960, + "tuesday": 960, + "wednesday": 960, + "thursday": 960, + "friday": 960, + "saturday": 960, + "sunday": 960, + }, + "itele": { #cnews + "monday": 960, + "tuesday": 960, + "wednesday": 960, + "thursday": 960, + "friday": 960, + "saturday": 960, + "sunday": 960, + }, + "france-inter": { + "monday": 480, + "tuesday": 480, + "wednesday": 480, + "thursday": 480, + "friday": 420, + "saturday": 330, + "sunday": 330, + }, + "rtl": { + "monday": 510, + "tuesday": 510, + "wednesday": 510, + "thursday": 510, + "friday": 510, + "saturday": 345, + "sunday": 405, + }, + "nrj": { + "monday": 480, + "tuesday": 480, + "wednesday": 480, + "thursday": 480, + "friday": 480, + "saturday": 0, + "sunday": 0, + }, + "rmc": { + "monday": 540, + "tuesday": 510, + "wednesday": 510, + "thursday": 510, + "friday": 510, + "saturday": 180, + "sunday": 180, + }, + "rtl2": { + "monday": 210, + "tuesday": 210, + "wednesday": 210, + "thursday": 210, + "friday": 210, + "saturday": 240, + "sunday": 240 + }, + "rfm": { + "monday": 210, + "tuesday": 210, + "wednesday": 210, + "thursday": 210, + "friday": 210, + "saturday": 0, + "sunday": 0, + }, + "europe1": { + "monday": 540, + "tuesday": 540, + "wednesday": 540, + "thursday": 540, + "friday": 540, + "saturday": 0, + "sunday": 0, + }, + "france-culture": { + "monday": 230, + "tuesday": 230, + "wednesday": 230, + "thursday": 230, + "friday": 230, + "saturday": 165, + "sunday": 0 + } +} + +## sql +# based on Mediatree Annexe 1 : Périmètre - minutes per +duration_by_channel_day = { + "tf1": { + "monday":80, + "tuesday":80, + "wednesday":80, + "thursday":80, + "friday":80, + "saturday":80, + "sunday":80, + }, + "france2": { + "monday": 80, + "tuesday": 80, + "wednesday": 80, + "thursday": 80, + "friday": 80, + "saturday": 160, + "sunday": 80, + }, + "france3": { + "monday": 100, + "tuesday": 100, + "wednesday": 100, + "thursday": 100, + "friday": 100, + "saturday": 100, + "sunday": 100, + }, + "france5": { + "monday": 205, + "tuesday": 205, + "wednesday": 205, + "thursday": 205, + "friday": 135, + "saturday": 140, + "sunday": 60, + }, + "m6": { + "monday": 100, + "tuesday": 100, + "wednesday": 100, + "thursday": 100, + "friday": 100, + "saturday": 100, + "sunday": 225, + }, + "arte": { + "monday": 65, + "tuesday": 65, + "wednesday": 65, + "thursday": 65, + "friday": 65, + "saturday": 65, + "sunday": 20, + }, + "d8": { + "monday": 140, + "tuesday": 140, + "wednesday": 140, + "thursday": 140, + "friday": 140, + "saturday": 0, + "sunday": 0, + }, + "tmc": { + "monday": 125, + "tuesday": 125, + "wednesday": 125, + "thursday": 125, + "friday": 125, + "saturday": 0, + "sunday": 0, + }, + "bfmtv": { + "monday": 960, + "tuesday": 960, + "wednesday": 960, + "thursday": 960, + "friday": 960, + "saturday": 960, + "sunday": 960, + }, + "lci": { + "monday": 960, + "tuesday": 960, + "wednesday": 960, + "thursday": 960, + "friday": 960, + "saturday": 960, + "sunday": 960, + }, + "franceInfo": { + "monday": 960, + "tuesday": 960, + "wednesday": 960, + "thursday": 960, + "friday": 960, + "saturday": 960, + "sunday": 960, + }, + "itele": { #cnews + "monday": 960, + "tuesday": 960, + "wednesday": 960, + "thursday": 960, + "friday": 960, + "saturday": 960, + "sunday": 960, + }, + "france-inter": { + "monday": 480, + "tuesday": 480, + "wednesday": 480, + "thursday": 480, + "friday": 420, + "saturday": 330, + "sunday": 330, + }, + "rtl": { + "monday": 510, + "tuesday": 510, + "wednesday": 510, + "thursday": 510, + "friday": 510, + "saturday": 345, + "sunday": 405, + }, + "nrj": { + "monday": 480, + "tuesday": 480, + "wednesday": 480, + "thursday": 480, + "friday": 480, + "saturday": 0, + "sunday": 0, + }, + "rmc": { + "monday": 540, + "tuesday": 510, + "wednesday": 510, + "thursday": 510, + "friday": 510, + "saturday": 180, + "sunday": 180, + }, + "rtl2": { + "monday": 210, + "tuesday": 210, + "wednesday": 210, + "thursday": 210, + "friday": 210, + "saturday": 240, + "sunday": 240 + }, + "rfm": { + "monday": 210, + "tuesday": 210, + "wednesday": 210, + "thursday": 210, + "friday": 210, + "saturday": 0, + "sunday": 0, + }, + "europe1": { + "monday": 540, + "tuesday": 540, + "wednesday": 540, + "thursday": 540, + "friday": 540, + "saturday": 0, + "sunday": 0, + }, + "france-culture": { + "monday": 230, + "tuesday": 230, + "wednesday": 230, + "thursday": 230, + "friday": 230, + "saturday": 165, + "sunday": 0 + } +} + + +CREATE TABLE channel_metadata ( + id SERIAL PRIMARY KEY, + channel_name VARCHAR(255) NOT NULL, + channel_title VARCHAR(255), + duration_minutes INTEGER NOT NULL, + weekday INTEGER NOT NULL +); + +INSERT INTO channel_metadata (channel_name, duration_minutes, weekday) +VALUES + ('tf1', 80, 2), + ('tf1', 80, 3), + ('tf1', 80, 4), + ('tf1', 80, 5), + ('tf1', 80, 6), + ('tf1', 80, 7), + ('tf1', 80, 1), + + ('france2', 80, 2), + ('france2', 80, 3), + ('france2', 80, 4), + ('france2', 80, 5), + ('france2', 80, 6), + ('france2', 160, 7), + ('france2', 80, 1), + + ('france3', 100, 2), + ('france3', 100, 3), + ('france3', 100, 4), + ('france3', 100, 5), + ('france3', 100, 6), + ('france3', 100, 7), + ('france3', 100, 1), + + ('france5', 205, 2), + ('france5', 205, 3), + ('france5', 205, 4), + ('france5', 205, 5), + ('france5', 135, 6), + ('france5', 140, 7), + ('france5', 60, 1), + + ('m6', 100, 2), + ('m6', 100, 3), + ('m6', 100, 4), + ('m6', 100, 5), + ('m6', 100, 6), + ('m6', 100, 7), + ('m6', 225, 1), + + ('arte', 65, 2), + ('arte', 65, 3), + ('arte', 65, 4), + ('arte', 65, 5), + ('arte', 65, 6), + ('arte', 65, 7), + ('arte', 20, 1), + + ('d8', 140, 2), + ('d8', 140, 3), + ('d8', 140, 4), + ('d8', 140, 5), + ('d8', 140, 6), + ('d8', 140, 7), + ('d8', 0, 1), + + ('tmc', 125, 2), + ('tmc', 125, 3), + ('tmc', 125, 4), + ('tmc', 125, 5), + ('tmc', 125, 6), + ('tmc', 125, 7), + ('tmc', 0, 1), + + ('bfmtv', 960, 2), + ('bfmtv', 960, 3), + ('bfmtv', 960, 4), + ('bfmtv', 960, 5), + ('bfmtv', 960, 6), + ('bfmtv', 960, 7), + ('bfmtv', 960, 1), + + ('lci', 960, 2), + ('lci', 960, 3), + ('lci', 960, 4), + ('lci', 960, 5), + ('lci', 960, 6), + ('lci', 960, 7), + ('lci', 960, 1), + + ('franceInfo', 960, 2), + ('franceInfo', 960, 3), + ('franceInfo', 960, 4), + ('franceInfo', 960, 5), + ('franceInfo', 960, 6), + ('franceInfo', 960, 7), + ('franceInfo', 960, 1), + + ('itele', 960, 2), + ('itele', 960, 3), + ('itele', 960, 4), + ('itele', 960, 5), + ('itele', 960, 6), + ('itele', 960, 7), + ('itele', 960, 1), + + ('france-inter', 480, 2), + ('france-inter', 480, 3), + ('france-inter', 480, 4), + ('france-inter', 480, 5), + ('france-inter', 420, 6), + ('france-inter', 330, 7), + ('france-inter', 330, 1), + + ('rtl', 510, 2), + ('rtl', 510, 3), + ('rtl', 510, 4), + ('rtl', 510, 5), + ('rtl', 510, 6), + ('rtl', 345, 7), + ('rtl', 405, 1), + + ('nrj', 480, 2), + ('nrj', 480, 3), + ('nrj', 480, 4), + ('nrj', 480, 5), + ('nrj', 480, 6), + ('nrj', 0, 7), + ('nrj', 0, 1), + + ('rmc', 540, 2), + ('rmc', 510, 3), + ('rmc', 510, 4), + ('rmc', 510, 5), + ('rmc', 510, 6), + ('rmc', 180, 7), + ('rmc', 180, 1), + + ('rtl2', 210, 2), + ('rtl2', 210, 3), + ('rtl2', 210, 4), + ('rtl2', 210, 5), + ('rtl2', 210, 6), + ('rtl2', 240, 7), + ('rtl2', 240, 1), + + ('rfm', 210, 2), + ('rfm', 210, 3), + ('rfm', 210, 4), + ('rfm', 210, 5), + ('rfm', 210, 6), + ('rfm', 0, 7), + ('rfm', 0, 1), + + ('europe1', 540, 2), + ('europe1', 540, 3), + ('europe1', 540, 4), + ('europe1', 540, 5), + ('europe1', 540, 6), + ('europe1', 0, 7), + ('europe1', 0, 1), + + ('france-culture', 230, 2), + ('france-culture', 230, 3), + ('france-culture', 230, 4), + ('france-culture', 230, 5), + ('france-culture', 230, 6), + ('france-culture', 165, 7), + ('france-culture', 0, 1); \ No newline at end of file