mirror of
https://github.com/Jylpah/blitz-tools.git
synced 2026-10-24 19:49:52 +02:00
Add "cache_only" param to get_**_stats() funcs
This commit is contained in:
1 parent
2438e76ba5
commit
f5eee3903f
1 file changed
+7
-2
+7
-2
@@ -926,7 +926,7 @@ class WG:
|
|||||||
return None
|
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[])"""
|
"""Get player's stats (WR, # of battles) in a tank or all tanks (empty tank_ids[])"""
|
||||||
try:
|
try:
|
||||||
stats = None
|
stats = None
|
||||||
@@ -936,6 +936,8 @@ class WG:
|
|||||||
stats = await self.get_cached_tank_stats(account_id, tank_ids, fields)
|
stats = await self.get_cached_tank_stats(account_id, tank_ids, fields)
|
||||||
if stats != None:
|
if stats != None:
|
||||||
return stats
|
return stats
|
||||||
|
if cache_only:
|
||||||
|
return None
|
||||||
|
|
||||||
# Cached stats not found, fetching new ones
|
# Cached stats not found, fetching new ones
|
||||||
url = self.get_url_player_tanks_stats(account_id, tank_ids, fields)
|
url = self.get_url_player_tanks_stats(account_id, tank_ids, fields)
|
||||||
@@ -951,7 +953,7 @@ class WG:
|
|||||||
return None
|
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 """
|
"""Get player's global stats """
|
||||||
try:
|
try:
|
||||||
#debug('account_id: ' + str(account_id) )
|
#debug('account_id: ' + str(account_id) )
|
||||||
@@ -964,6 +966,9 @@ class WG:
|
|||||||
return stats
|
return stats
|
||||||
|
|
||||||
except StatsNotFound as err:
|
except StatsNotFound as err:
|
||||||
|
if cache_only:
|
||||||
|
return None
|
||||||
|
|
||||||
# No cached stats found, need to retrieve
|
# No cached stats found, need to retrieve
|
||||||
debug(exception=err)
|
debug(exception=err)
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in new issue
Block a user