From 4c31faf49a924420768675843768b9625113a972 Mon Sep 17 00:00:00 2001 From: james Date: Fri, 20 Oct 2023 03:40:42 +0800 Subject: [PATCH] Add categories overview api --- backend/api_app/controllers/apps.py | 11 ----------- backend/api_app/models.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/backend/api_app/controllers/apps.py b/backend/api_app/controllers/apps.py index 11ef684..5f9fb27 100644 --- a/backend/api_app/controllers/apps.py +++ b/backend/api_app/controllers/apps.py @@ -22,17 +22,6 @@ def get_string_date_from_days_ago(days: int) -> str: return mydate_str -def category_overview() -> dict: - cats = get_appstore_categories() - # Make app count strings - cats["android"] = cats["android"].apply( - lambda x: "{:,.0f}".format(x) if x else "N/A" - ) - cats["ios"] = cats["ios"].apply(lambda x: "{:,.0f}".format(x) if x else "N/A") - category_dicts = cats.to_dict(orient="records") - return category_dicts - - def get_app_overview_dict() -> AppsOverview: new_apps = query_recent_apps(period="weekly") trending_apps = query_recent_apps(period="monthly") diff --git a/backend/api_app/models.py b/backend/api_app/models.py index cbfe578..6f66f6a 100644 --- a/backend/api_app/models.py +++ b/backend/api_app/models.py @@ -13,3 +13,15 @@ class AppsOverview: new_google: list[AppDetail] trending_google: list[AppDetail] trending_ios: list[AppDetail] + + +@dataclass +class CategoryDetail: + category: str + installs: int + reviews: int + + +@dataclass +class CategoriesOverview: + data: list[CategoryDetail]