refactored-get-author-3
All checks were successful
Deploy on push / deploy (push) Successful in 23s

This commit is contained in:
Untone 2024-03-28 19:08:55 +03:00
parent 8826af02b5
commit 9d8831d7ed
3 changed files with 3 additions and 0 deletions

View File

@ -71,6 +71,7 @@ async def get_author(_, _info, slug='', author_id=None):
q = select(Author).where(Author.id == author_id) q = select(Author).where(Author.id == author_id)
[author] = await get_authors_with_stat_cached(q) [author] = await get_authors_with_stat_cached(q)
if author: if author:
logger.debug(f'queried author from db {cache_key} -> {cache}')
author_dict = author.dict() author_dict = author.dict()
else: else:
logger.warn('author was not cached!') logger.warn('author was not cached!')

View File

@ -197,6 +197,7 @@ def get_with_stat(q):
async def get_authors_with_stat_cached(q): async def get_authors_with_stat_cached(q):
logger.debug(q)
try: try:
records = [] records = []
with local_session() as session: with local_session() as session:

View File

@ -93,6 +93,7 @@ def before_cursor_execute(conn, cursor, statement, parameters, context, executem
conn.query_start_time = time.time() conn.query_start_time = time.time()
conn.last_statement = '' conn.last_statement = ''
@event.listens_for(Engine, 'after_cursor_execute') @event.listens_for(Engine, 'after_cursor_execute')
def after_cursor_execute(conn, cursor, statement, parameters, context, executemany): def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
compiled_statement = context.compiled.string compiled_statement = context.compiled.string