This commit is contained in:
parent
32bc750071
commit
2e2eba68a2
|
@ -22,7 +22,7 @@ async def request_data(gql, headers=None):
|
||||||
return data
|
return data
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Handling and logging exceptions during authentication check
|
# Handling and logging exceptions during authentication check
|
||||||
logger.error(f'[services.auth] request_data error: {e}')
|
logger.error(f'request_data error: {e}')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ async def check_auth(req):
|
||||||
|
|
||||||
|
|
||||||
async def add_user_role(user_id):
|
async def add_user_role(user_id):
|
||||||
logger.info(f'[services.auth] add author role for user_id: {user_id}')
|
logger.info(f'add author role for user_id: {user_id}')
|
||||||
query_name = '_update_user'
|
query_name = '_update_user'
|
||||||
operation = 'UpdateUserRoles'
|
operation = 'UpdateUserRoles'
|
||||||
headers = {
|
headers = {
|
||||||
|
|
|
@ -19,20 +19,19 @@ cache_region = make_region().configure('dogpile.cache.memory', expiration_time=3
|
||||||
engine = create_engine(DB_URL, echo=False, pool_size=10, max_overflow=20)
|
engine = create_engine(DB_URL, echo=False, pool_size=10, max_overflow=20)
|
||||||
T = TypeVar('T')
|
T = TypeVar('T')
|
||||||
REGISTRY: Dict[str, type] = {}
|
REGISTRY: Dict[str, type] = {}
|
||||||
Base = declarative_base()
|
|
||||||
|
|
||||||
|
|
||||||
# Перехватчики для журнала запросов SQLAlchemy
|
# Перехватчики для журнала запросов SQLAlchemy
|
||||||
@event.listens_for(Engine, 'before_cursor_execute')
|
@event.listens_for(Engine, 'before_cursor_execute')
|
||||||
def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
|
def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
|
||||||
conn._query_start_time = time.time()
|
conn.query_start_time = time.time()
|
||||||
|
|
||||||
|
|
||||||
@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):
|
||||||
if hasattr(conn, '_query_start_time'):
|
if hasattr(conn, '_query_start_time'):
|
||||||
elapsed = time.time() - conn._query_start_time
|
elapsed = time.time() - conn.query_start_time
|
||||||
del conn._query_start_time
|
del conn.query_start_time
|
||||||
if elapsed > 0.9: # Adjust threshold as needed
|
if elapsed > 0.9: # Adjust threshold as needed
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"\n{statement}\n{'*' * math.floor(elapsed)} {elapsed:.3f} s"
|
f"\n{statement}\n{'*' * math.floor(elapsed)} {elapsed:.3f} s"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user