@@ -72,7 +72,7 @@ def api_call_dfs(state: State, store_id: str) -> pd.DataFrame:
7272 return df
7373
7474
75- def get_search_results (state : State , search_term : str ) -> dict :
75+ def get_search_results (state : State , search_term : str ) -> AppGroupByStore :
7676 """Parse search term and return resulting AppGroup."""
7777 decoded_input = urllib .parse .unquote (search_term )
7878 decoded_input = decoded_input .strip ()
@@ -81,10 +81,12 @@ def get_search_results(state: State, search_term: str) -> dict:
8181 df = search_apps (state , search_input = decoded_input , limit = 60 )
8282 df = extend_app_icon_url (df )
8383 logger .info (f"{ decoded_input = } returned rows: { df .shape [0 ]} " )
84- apple_apps_dict = df [df ["store" ].str .startswith ("Apple" )].to_dict (orient = "records" )
85- google_apps_dict = df [df ["store" ].str .startswith ("Google" )].to_dict (
84+ apple_apps_dict : list [AppDetail ] = df [df ["store" ].str .startswith ("Apple" )].to_dict (
8685 orient = "records"
8786 )
87+ google_apps_dict : list [AppDetail ] = df [
88+ df ["store" ].str .startswith ("Google" )
89+ ].to_dict (orient = "records" )
8890 app_group = AppGroupByStore (
8991 key = f"Apps matching '{ search_term } '" ,
9092 apple = AppGroup (title = "Apple" , apps = apple_apps_dict ),
@@ -337,7 +339,7 @@ async def get_new_apps(
337339 @get (path = "/growth/{store:int}" , cache = 86400 )
338340 async def get_growth_apps (
339341 self : Self , state : State , store : int , app_category : str | None = None
340- ) -> list [ dict ] :
342+ ) -> dict :
341343 """Handle GET request for a list of fastest growing apps.
342344
343345 Args:
@@ -555,7 +557,7 @@ async def get_sdk_details(self: Self, state: State, store_id: str) -> SDKsDetail
555557
556558 cats = df .loc [df ["category_slug" ].notna (), "category_slug" ].unique ().tolist ()
557559 company_sdk_dict = {}
558- found_sdk_tlds = []
560+ found_sdk_tlds : list = []
559561 # example: {"ad-networks":
560562 # {"bytedance.com":
561563 # {"com.bytedance.sdk":
@@ -833,7 +835,7 @@ async def request_sdk_scan(
833835 insert_sdk_scan_request (state , store_id , user_id )
834836 return {"status" : "success" }
835837
836- @get (path = "/{store_id:str}/keywords" , cache = 86400 )
838+ @get (path = "/{store_id:str}/keywords" , cache = 3600 )
837839 async def get_app_keywords (self : Self , state : State , store_id : str ) -> dict :
838840 """Handle GET request for a list of apps.
839841
@@ -851,7 +853,7 @@ async def get_app_keywords(self: Self, state: State, store_id: str) -> dict:
851853 logger .info (f"{ self .path } /{ store_id } /keywords took { duration } ms" )
852854 return keywords_dict
853855
854- @get (path = "/{store_id:str}/apis" , cache = 86400 )
856+ @get (path = "/{store_id:str}/apis" , cache = 3600 )
855857 async def get_app_apis (self : Self , state : State , store_id : str ) -> dict :
856858 """Handle GET request for a list of apps.
857859
@@ -885,6 +887,7 @@ async def get_crossfilter_apps(self: Self, state: State, data: dict) -> dict:
885887 require_sdk_api = bool (data .get ("require_sdk_api" , False ))
886888 require_iap = bool (data .get ("require_iap" , False ))
887889 require_ads = bool (data .get ("require_ads" , False ))
890+ ranking_country = data .get ("ranking_country" )
888891 mydate = data .get ("mydate" , "2024-01-01" )
889892 category = data .get ("category" )
890893 store = data .get ("store" )
@@ -894,8 +897,6 @@ async def get_crossfilter_apps(self: Self, state: State, data: dict) -> dict:
894897 max_rating_count = data .get ("max_rating_count" )
895898 min_installs_d30 = data .get ("min_installs_d30" )
896899 max_installs_d30 = data .get ("max_installs_d30" )
897- sort_col = data .get ("sort_col" , "installs" )
898- sort_order = data .get ("sort_order" , "desc" )
899900
900901 # Ensure domains are lists of strings
901902 if isinstance (include_domains , str ):
@@ -906,12 +907,14 @@ async def get_crossfilter_apps(self: Self, state: State, data: dict) -> dict:
906907 # Filter out empty strings
907908 include_domains = [d for d in include_domains if d and isinstance (d , str )]
908909 exclude_domains = [d for d in exclude_domains if d and isinstance (d , str )]
910+ if ranking_country is not None :
911+ ranking_country = str (ranking_country ).strip () or None
909912
910913 logger .info (
911914 f"Crossfilter query: include={ len (include_domains )} domains, "
912915 f"exclude={ len (exclude_domains )} domains, sdk_api={ require_sdk_api } , "
913- f"iap={ require_iap } , ads={ require_ads } , date={ mydate } , "
914- f"category={ category } , store={ store } , sort= { sort_col } { sort_order } "
916+ f"iap={ require_iap } , ads={ require_ads } , ranking_country= { ranking_country } , date={ mydate } , "
917+ f"category={ category } , store={ store } "
915918 )
916919
917920 try :
@@ -922,6 +925,7 @@ async def get_crossfilter_apps(self: Self, state: State, data: dict) -> dict:
922925 require_sdk_api = require_sdk_api ,
923926 require_iap = require_iap ,
924927 require_ads = require_ads ,
928+ ranking_country = ranking_country ,
925929 mydate = mydate ,
926930 category = category ,
927931 store = store ,
@@ -931,8 +935,6 @@ async def get_crossfilter_apps(self: Self, state: State, data: dict) -> dict:
931935 max_rating_count = max_rating_count ,
932936 min_installs_d30 = min_installs_d30 ,
933937 max_installs_d30 = max_installs_d30 ,
934- sort_col = sort_col ,
935- sort_order = sort_order ,
936938 )
937939 apps_df = extend_app_icon_url (apps_df )
938940 apps_list = apps_df .to_dict (orient = "records" )
0 commit comments