from apollo_utils.core.constants.dsp import DSP from src import config from src.constants import DataType from src.constants.queries.mysql.weekly_top_playlists import DESTINATION_TABLE_WEEKLY_TOP_PLAYLISTS, \ DOWNLOAD_COLUMNS_WEEKLY_TOP_PLAYLISTS, ID_COLUMN_WEEKLY_TOP_PLAYLISTS from src.constants.queries.snowflake.weekly_top_playlists import WEEKLY_TOP_PLAYLISTS from src.processors.base import BaseProcessor class WeeklyTopPlaylistsProcessor(BaseProcessor): _data_type = DataType.WEEKLY_TOP_PLAYLISTS _save_temp_table = True _snowflake_query = WEEKLY_TOP_PLAYLISTS _destination_table = DESTINATION_TABLE_WEEKLY_TOP_PLAYLISTS _destination_columns = DOWNLOAD_COLUMNS_WEEKLY_TOP_PLAYLISTS _id_column = ID_COLUMN_WEEKLY_TOP_PLAYLISTS @property def snowflake_query(self) -> str: return self._snowflake_query[self._dsp].format( top_database=( config.Snowflake.PUBLIC_DATA_MAIN_DATABASE if self._dsp == DSP.SPOTIFY.value else config.Snowflake.EXPLORATION_DATABASE ), top_schema=( config.Snowflake.PUBLIC_DATA_MAIN_PLAYLISTS_SCHEMA if self._dsp == DSP.SPOTIFY.value else config.Snowflake.EXPLORATION_MAIN_SCHEMA ), ) @property def destination_table(self) -> str: return self._destination_table[self._dsp] def parse_type_specific_data(self): self._dsp = self._payload["dsp"] if self._dsp not in (DSP.SPOTIFY.value, DSP.APPLE.value): raise ValueError(f"Invalid dsp {self._dsp}")