from aiohttp.web import Request, Response, json_response from server.legacy.consumer_analytics import util async def get_first_stream_dates(request: Request, vendor: str or None = None, wrap_response: bool = False): api = request.app["delphi_java_api"] data = request["querystring"] if vendor: data["vendor"] = vendor result = await util.get_track_first_stream_date(api, wrap_response=wrap_response, **data) return json_response(result) async def get_tracks_per_country( request: Request, exclude_global: bool, include_owner_categories: bool, vendor: str = None ) -> Response: api = request.app["delphi_java_api"] data = request["querystring"] result = await util.get_streams_per_country( api, data["isrc"], data.get("vendor", vendor), data["start_date"], data["end_date"], data.get("streams_only", False), exclude_global=exclude_global, include_owner_categories=include_owner_categories, ) return json_response(result) async def get_track_playlist_summary_view( request: Request, vendor: str, include_shuffle: bool = False, per_day: bool = False, include_summary: bool = False, all_markets: bool = False, ) -> Response: api = request.app["delphi_java_api"] data = request["querystring"] result = await util.get_tracks_playlists_summary( api, data.get("isrc") or data["isrc_list"], vendor, data["start_date"], data["end_date"], data.get("market"), data.get("playlist_id"), include_shuffle=include_shuffle, per_day=per_day, include_summary=include_summary, all_markets=all_markets, ) return json_response(result)