55from app .config import settings
66from app .overfast_logger import logger
77from app .parsers import JSONParser
8- from app .unlocks_manager import UnlocksManager
98
109from ..helpers import get_player_title
1110
@@ -21,7 +20,6 @@ def __init__(self, **kwargs):
2120 self .order_by = kwargs .get ("order_by" )
2221 self .offset = kwargs .get ("offset" )
2322 self .limit = kwargs .get ("limit" )
24- self .unlocks_manager = UnlocksManager ()
2523
2624 def get_blizzard_url (self , ** kwargs ) -> str :
2725 """URL used when requesting data to Blizzard."""
@@ -34,7 +32,7 @@ async def parse_data(self) -> dict:
3432
3533 # Transform into PlayerSearchResult format
3634 logger .info ("Applying transformation.." )
37- players = await self .apply_transformations (players )
35+ players = self .apply_transformations (players )
3836
3937 # Apply ordering
4038 logger .info ("Applying ordering.." )
@@ -58,31 +56,26 @@ def filter_players(self) -> list[dict]:
5856 battletag = self .search_nickname .replace ("-" , "#" )
5957 return [player for player in self .json_data if player ["battleTag" ] == battletag ]
6058
61- async def apply_transformations (self , players : Iterable [dict ]) -> list [dict ]:
59+ def apply_transformations (self , players : Iterable [dict ]) -> list [dict ]:
6260 """Apply transformations to found players in order to return the data
6361 in the OverFast API format. We'll also retrieve some data from parsers.
6462 """
6563 transformed_players = []
6664
67- # Retrieve and cache Unlock IDs
68- unlock_ids = self .__retrieve_unlock_ids (players )
69- await self .unlocks_manager .cache_values (unlock_ids )
70-
7165 for player in players :
7266 player_id = player ["battleTag" ].replace ("#" , "-" )
7367
7468 transformed_players .append (
7569 {
7670 "player_id" : player_id ,
7771 "name" : player ["battleTag" ],
78- "avatar" : self .unlocks_manager .get (player ["portrait" ]),
79- "namecard" : self .unlocks_manager .get (player ["namecard" ]),
80- "title" : get_player_title (
81- self .unlocks_manager .get (player ["title" ])
82- ),
72+ "avatar" : player ["avatar" ],
73+ "namecard" : player .get ("namecard" ),
74+ "title" : get_player_title (player ["title" ]),
8375 "career_url" : f"{ settings .app_base_url } /players/{ player_id } " ,
8476 "blizzard_id" : player ["url" ],
8577 "last_updated_at" : player ["lastUpdated" ],
78+ "is_public" : player ["isPublic" ],
8679 },
8780 )
8881 return transformed_players
@@ -95,6 +88,3 @@ def apply_ordering(self, players: list[dict]) -> list[dict]:
9588 reverse = order_arrangement == "desc" ,
9689 )
9790 return players
98-
99- def __retrieve_unlock_ids (self , players : list [dict ]) -> set [str ]:
100- return {player [key ] for player in players for key in settings .unlock_keys }
0 commit comments