stat-fix
All checks were successful
Deploy on push / deploy (push) Successful in 23s

This commit is contained in:
Untone 2024-03-28 19:14:39 +03:00
parent 2d538a292a
commit a4957ef0ad

View File

@ -197,14 +197,13 @@ def get_with_stat(q):
async def get_authors_with_stat_cached(q): async def get_authors_with_stat_cached(q):
logger.debug(q) # logger.debug(q)
try: try:
records = [] records = []
with local_session() as session: with local_session() as session:
for [x] in session.execute(q): for [x] in session.execute(q):
stat_str = await redis.execute('GET', f'author:{x.id}') stat_str = await redis.execute('GET', f'author:{x.id}')
if isinstance(stat_str, str): x.stat = json.loads(stat_str).get('stat') if isinstance(stat_str, str) else {}
x.stat = json.loads(stat_str).get('stat')
records.append(x) records.append(x)
except Exception as exc: except Exception as exc:
raise Exception(exc) raise Exception(exc)