mirror of
https://github.com/norohind/SquadsActivityMonitor.git
synced 2026-10-25 01:06:03 +03:00
WIP: model.get_leaderboard_sum_history and all appropriate stuff
This commit is contained in:
6 files changed
+128
-1
No files matched your search
@@ -143,3 +143,26 @@ class PostgresModel(AbstractModel):
|
||||
cache.set(cache_key, json.dumps(result))
|
||||
|
||||
return result
|
||||
|
||||
@errors_catcher
|
||||
def get_leaderboard_sum_history(self, platform: str, leaderboard_type: str) -> list[dict]:
|
||||
cache_key = f'sum_history_{platform}_{leaderboard_type}'
|
||||
cached_result: typing.Union[str, None] = cache.get(cache_key)
|
||||
|
||||
if cached_result is not None:
|
||||
logger.debug(f'Cached result for {cache_key}')
|
||||
return json.loads(cached_result)
|
||||
|
||||
with self.db.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cursor:
|
||||
cursor.execute(
|
||||
postgres_sql_requests.select_leaderboard_sum_history,
|
||||
{
|
||||
'LB_type': utils.LeaderboardTypes(leaderboard_type.lower()).value,
|
||||
'platform': utils.Platform(platform.upper()).value}
|
||||
)
|
||||
result: list = cursor.fetchall()
|
||||
|
||||
if not cache.disabled:
|
||||
cache.set(cache_key, json.dumps(result))
|
||||
|
||||
return result
|
||||
Reference in new issue
Block a user