# ChartDefinition is a legacy logic from Insights where they store the same dataset on a FE side to solve the problems # for chart names, size e.t.c. because of some wrong and outdated data from DB that needs to be fixed by the data team # The reason of storing the same information is to be aligned and consistent with Insights. # This can be removed only when the data in DB will be fixed and up to date from typing import Any, Dict, Tuple from charts.utils.chart_definition_key import _create_chart_definition_key ChartDefinition = ( { "storeName": "Spotify", "name": "Daily Viral 100", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": False, "size": 100, "id": { "type": "viral", "platform": "spotify", "target": "track", "frequency": "daily", }, }, { "storeName": "Spotify", "name": "Daily Top 200", "hasStreamCount": True, "hasShazams": False, "hasTotalStreamCount": False, "size": 200, "id": { "type": "regional", "platform": "spotify", "target": "track", "frequency": "daily", }, }, { "storeName": "Spotify", "name": "Weekly Top 200", "hasStreamCount": True, "hasShazams": False, "hasTotalStreamCount": False, "size": 200, "id": { "type": "regional", "platform": "spotify", "target": "track", "frequency": "weekly", }, }, { "storeName": "Apple Music", "name": "Daily Top 100", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": False, "size": 100, "id": { "type": "default", "platform": "appleMusic", "target": "track", "frequency": "daily", }, }, { "storeName": "Deezer", "name": "Daily Top 100", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": False, "size": 100, "id": { "type": "default", "platform": "deezer", "target": "track", "frequency": "daily", }, }, { "storeName": "TikTok", "name": "All Time Top Tracks", "hasStreamCount": True, "hasShazams": False, "hasTotalStreamCount": False, "linkName": "allTime", "size": 1000, "id": { "type": "default", "platform": "tiktok", "target": "track", "frequency": "daily", }, }, { "storeName": "TikTok", "name": "Weekly Top Tracks", "hasStreamCount": True, "hasShazams": False, "hasTotalStreamCount": False, "timeOnChart": "daily", "size": 1000, "id": { "type": "default", "platform": "tiktok", "target": "track", "frequency": "weekly", }, }, { "storeName": "SoundCloud", "name": "Daily Top Tracks", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": True, "size": 200, "id": { "type": "top", "platform": "soundcloud", "target": "track", "frequency": "daily", }, }, { "storeName": "SoundCloud", "name": "Daily New & Hot", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": True, "size": 200, "id": { "type": "trending", "platform": "soundcloud", "target": "track", "frequency": "daily", }, }, { "storeName": "Recochoku (Japan)", "name": "Daily Top 200", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": False, "size": 200, "id": { "type": "single", "platform": "recochoku", "target": "track", "frequency": "daily", }, }, { "storeName": "Recochoku (Japan)", "name": "Weekly Top 200", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": False, "size": 200, "id": { "type": "single", "platform": "recochoku", "target": "track", "frequency": "weekly", }, }, { "storeName": "Line Music (Japan)", "name": "Daily Top 100", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": False, "size": 100, "id": { "type": "Top 100", "platform": "linemusic", "target": "track", "frequency": "daily", }, }, { "storeName": "Line Music (Japan)", "name": "Weekly Top 100", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": False, "size": 100, "id": { "type": "Top 100", "platform": "linemusic", "target": "track", "frequency": "weekly", }, }, { "storeName": "Shazam", "name": "Daily Top Tracks", "hasStreamCount": False, "hasShazams": True, "hasTotalStreamCount": False, "size": 200, "id": { "type": "default", "platform": "shazam", "target": "track", "frequency": "daily", }, }, { "storeName": "YouTube", "name": "Top Songs", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": False, "size": 200, "id": { "type": "Tracks", "platform": "youtube", "target": "track", "frequency": "weekly", }, }, { "storeName": "YouTube", "name": "Top Videos", "hasStreamCount": False, "hasShazams": False, "hasTotalStreamCount": False, "size": 200, "id": { "type": "Music Videos", "platform": "youtube", "target": "video", "frequency": "weekly", }, }, # Added Amazon not to get an error when requested { "storeName": "Amazon", "name": "Amazon Daily", "id": { "type": "default", "platform": "amazon", "target": "", "frequency": "daily", }, } ) def get_chart_names_mappings(data: Tuple[Dict[str, Any]] = ChartDefinition): """Get custom definition key to chart name mapping Args: data: Tuple of chart information dicts Returns: Dict with chart_definition_key to chart_name mapping Examples: { "spotify_regional_daily": "Daily Top 200", "applemusic_default_daily": "Daily Top 100", e.t.c }, """ return {_create_chart_definition_key(item["id"]): item["name"] for item in data} CHART_DEFINITION_KEY_TO_CHART_NAME_MAPPING = get_chart_names_mappings()