Merge branch 'master' into VORKOUT-7
This commit is contained in:
@@ -56,10 +56,7 @@ async def get_user_by_id(connection: AsyncConnection, id: int) -> Optional[User]
|
||||
"""
|
||||
Получает юзера по id.
|
||||
"""
|
||||
query = (
|
||||
select(account_table)
|
||||
.where(account_table.c.id == id)
|
||||
)
|
||||
query = select(account_table).where(account_table.c.id == id)
|
||||
|
||||
user_db_cursor = await connection.execute(query)
|
||||
user_db = user_db_cursor.one_or_none()
|
||||
@@ -68,8 +65,11 @@ async def get_user_by_id(connection: AsyncConnection, id: int) -> Optional[User]
|
||||
return None
|
||||
|
||||
user_data = {
|
||||
column.name: (getattr(user_db, column.name).name if isinstance(
|
||||
getattr(user_db, column.name), Enum) else getattr(user_db, column.name))
|
||||
column.name: (
|
||||
getattr(user_db, column.name).name
|
||||
if isinstance(getattr(user_db, column.name), Enum)
|
||||
else getattr(user_db, column.name)
|
||||
)
|
||||
for column in account_table.columns
|
||||
}
|
||||
|
||||
@@ -80,10 +80,7 @@ async def get_user_by_login(connection: AsyncConnection, login: str) -> Optional
|
||||
"""
|
||||
Получает юзера по login.
|
||||
"""
|
||||
query = (
|
||||
select(account_table)
|
||||
.where(account_table.c.login == login)
|
||||
)
|
||||
query = select(account_table).where(account_table.c.login == login)
|
||||
|
||||
user_db_cursor = await connection.execute(query)
|
||||
user_db = user_db_cursor.one_or_none()
|
||||
@@ -92,8 +89,11 @@ async def get_user_by_login(connection: AsyncConnection, login: str) -> Optional
|
||||
return None
|
||||
|
||||
user_data = {
|
||||
column.name: (getattr(user_db, column.name).name if isinstance(
|
||||
getattr(user_db, column.name), Enum) else getattr(user_db, column.name))
|
||||
column.name: (
|
||||
getattr(user_db, column.name).name
|
||||
if isinstance(getattr(user_db, column.name), Enum)
|
||||
else getattr(user_db, column.name)
|
||||
)
|
||||
for column in account_table.columns
|
||||
}
|
||||
|
||||
@@ -104,11 +104,7 @@ async def update_user_by_id(connection: AsyncConnection, update_values, user) ->
|
||||
"""
|
||||
Вносит изменеия в нужное поле таблицы account_table.
|
||||
"""
|
||||
await connection.execute(
|
||||
account_table.update()
|
||||
.where(account_table.c.id == user.id)
|
||||
.values(**update_values)
|
||||
)
|
||||
await connection.execute(account_table.update().where(account_table.c.id == user.id).values(**update_values))
|
||||
|
||||
await connection.commit()
|
||||
|
||||
@@ -126,7 +122,7 @@ async def create_user(connection: AsyncConnection, user: User, creator_id: int)
|
||||
meta=user.meta,
|
||||
creator_id=creator_id,
|
||||
created_at=datetime.now(timezone.utc),
|
||||
status=user.status.value
|
||||
status=user.status.value,
|
||||
)
|
||||
|
||||
await connection.execute(query)
|
||||
|
Reference in New Issue
Block a user