"""Logic for Timeseries Endpoints """ from owsresponse import response from socials.connectors import snowflake from socials.models import stats as stats_model from socials.models import pending as pending_model from socials.utils.pending import merge_pending_social_accounts SQLLoader = snowflake.SQLLoader(__file__) def get_stats(account_id): """Logic handlers. Args: account_id (str): the name to display alongside the Hello. Returns: Response: the hello message. """ return response.Response(stats_model.get_stats(account_id)) def get_stats_by_account(account_id, identity_id, platform=None): """Logic handlers. Args: account_id (str): the name to display alongside the Hello. Returns: Response: the hello message. """ pending_accounts = pending_model.get_pending_social_accounts(account_id, identity_id) stats = stats_model.get_stats_by_account(account_id, platform) return response.Response(merge_pending_social_accounts(stats, pending_accounts)) def get_stats_by_account_url(account_url): """Get stats by account URL. Args: account_url (str): social account URL Returns: Response: dict with properties of AggregatedSocialAccountStatV2 graphql type. """ return response.Response(stats_model.get_stats_by_account_url(account_url)) def get_stats_by_artists_ids(accounts_ids): """Get stats by artists ids. Args: artists_ids (list(int)): list of chartmetric ids of artists Returns: Response: list of response. """ return response.Response(stats_model.get_stats_by_artists_ids(accounts_ids))