Add logging for user updates and superuser status changes in CRUD and admin handlers. Fix user attribute indexing in database operations. Enhance user creation logging in user service.
This commit is contained in:
@@ -269,6 +269,8 @@ class UserCRUD(BaseCRUD):
|
||||
@track_db_operation("UPDATE", "users")
|
||||
async def update(self, user: User) -> User:
|
||||
"""Обновление пользователя"""
|
||||
if self.logger:
|
||||
self.logger.info(f"👤 Обновление пользователя: {user.telegram_id} (is_superuser: {user.is_superuser})")
|
||||
async with self.get_connection() as conn:
|
||||
await conn.execute("""
|
||||
UPDATE users SET
|
||||
@@ -284,6 +286,8 @@ class UserCRUD(BaseCRUD):
|
||||
user.ban_reason, user.telegram_id
|
||||
))
|
||||
await conn.commit()
|
||||
if self.logger:
|
||||
self.logger.info(f"✅ Пользователь обновлен: {user.telegram_id}")
|
||||
return user
|
||||
|
||||
@track_db_operation("DELETE", "users")
|
||||
@@ -386,11 +390,11 @@ class UserCRUD(BaseCRUD):
|
||||
chat_id=row[5],
|
||||
profile_link=row[6],
|
||||
is_active=bool(row[7]),
|
||||
is_superuser=bool(row[12]), # Исправлено: is_superuser находится на позиции 12
|
||||
created_at=self._parse_datetime(row[8]),
|
||||
updated_at=self._parse_datetime(row[9]),
|
||||
banned_until=self._parse_datetime(row[10]),
|
||||
ban_reason=row[11]
|
||||
is_superuser=bool(row[8]), # Исправлено: is_superuser находится на позиции 8
|
||||
created_at=self._parse_datetime(row[9]),
|
||||
updated_at=self._parse_datetime(row[10]),
|
||||
banned_until=self._parse_datetime(row[11]),
|
||||
ban_reason=row[12]
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user