Add "cache_only" param to get_**_stats() funcs

This commit is contained in:
Jylpah committed 2020-07-01 16:13:25 +03:00
1 parent 2438e76ba5
commit f5eee3903f
1 file changed
+7 -2
+7 -2
View File
@@ -926,7 +926,7 @@ class WG:
return None
async def get_player_tank_stats(self, account_id: int, tank_ids = [], fields = [], cache=True) -> dict:
async def get_player_tank_stats(self, account_id: int, tank_ids = [], fields = [], cache=True, cache_only = False) -> dict:
"""Get player's stats (WR, # of battles) in a tank or all tanks (empty tank_ids[])"""
try:
stats = None
@@ -936,6 +936,8 @@ class WG:
stats = await self.get_cached_tank_stats(account_id, tank_ids, fields)
if stats != None:
return stats
if cache_only:
return None
# Cached stats not found, fetching new ones
url = self.get_url_player_tanks_stats(account_id, tank_ids, fields)
@@ -951,7 +953,7 @@ class WG:
return None
async def get_player_stats(self, account_id: int, fields = [], cache=True) -> dict:
async def get_player_stats(self, account_id: int, fields = [], cache=True, cache_only = False) -> dict:
"""Get player's global stats """
try:
#debug('account_id: ' + str(account_id) )
@@ -964,6 +966,9 @@ class WG:
return stats
except StatsNotFound as err:
if cache_only:
return None
# No cached stats found, need to retrieve
debug(exception=err)
pass