From f5eee3903fdbe00f3be0b48ab69806ba14b7b36b Mon Sep 17 00:00:00 2001 From: Jylpah Date: Wed, 1 Jul 2020 16:13:25 +0300 Subject: [PATCH] Add "cache_only" param to get_**_stats() funcs --- blitzutils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/blitzutils.py b/blitzutils.py index aff294e..f162781 100644 --- a/blitzutils.py +++ b/blitzutils.py @@ -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