mirror of
https://github.com/norohind/SquadsActivityMonitor.git
synced 2025-04-15 06:10:33 +03:00
remove context manager self.db for read request
This commit is contained in:
parent
f58df5e45f
commit
0c64bde728
@ -63,17 +63,16 @@ class PostgresModel(AbstractModel):
|
|||||||
|
|
||||||
logger.debug(f'Not cached result for {cache_key}')
|
logger.debug(f'Not cached result for {cache_key}')
|
||||||
|
|
||||||
with self.db:
|
with self.db.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cursor:
|
||||||
with self.db.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cursor:
|
cursor.execute(postgres_sql_requests.select_activity_pretty_names, {
|
||||||
cursor.execute(postgres_sql_requests.select_activity_pretty_names, {
|
'LB_type': utils.LeaderboardTypes(leaderboard_type.lower()).value,
|
||||||
'LB_type': utils.LeaderboardTypes(leaderboard_type.lower()).value,
|
'platform': utils.Platform(platform.upper()).value,
|
||||||
'platform': utils.Platform(platform.upper()).value,
|
'limit': limit,
|
||||||
'limit': limit,
|
'high_timestamp': high_timestamp,
|
||||||
'high_timestamp': high_timestamp,
|
'low_timestamp': low_timestamp
|
||||||
'low_timestamp': low_timestamp
|
})
|
||||||
})
|
|
||||||
|
|
||||||
result: list = cursor.fetchall()
|
result: list = cursor.fetchall()
|
||||||
|
|
||||||
if not cache.disabled:
|
if not cache.disabled:
|
||||||
cache.set(cache_key, json.dumps(result))
|
cache.set(cache_key, json.dumps(result))
|
||||||
@ -136,10 +135,9 @@ class PostgresModel(AbstractModel):
|
|||||||
|
|
||||||
logger.debug(f'Not cached result for {cache_key}')
|
logger.debug(f'Not cached result for {cache_key}')
|
||||||
|
|
||||||
with self.db:
|
with self.db.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cursor:
|
||||||
with self.db.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cursor:
|
cursor.execute(postgres_sql_requests.select_diff_by_action_id, {'action_id': action_id})
|
||||||
cursor.execute(postgres_sql_requests.select_diff_by_action_id, {'action_id': action_id})
|
result: list = cursor.fetchall()
|
||||||
result: list = cursor.fetchall()
|
|
||||||
|
|
||||||
if not cache.disabled:
|
if not cache.disabled:
|
||||||
cache.set(cache_key, json.dumps(result))
|
cache.set(cache_key, json.dumps(result))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user