Files
wehub-resource-sync 1443d3fdf9
Ruff Format Check / Ruff Format & Lint (push) Failing after 7m39s
Deploy VitePress site to Pages / build (push) Failing after 9m11s
Deploy VitePress site to Pages / Deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:32:26 +08:00

19 lines
570 B
Python

from fastapi import Request
from sqlalchemy.ext.asyncio import AsyncSession
from yuxi.storage.postgres.models_business import OperationLog
async def log_operation(
db: AsyncSession,
user_id: int | None,
operation: str,
details: str | None = None,
request: Request | None = None,
) -> None:
try:
ip_address = request.client.host if request and request.client else None
db.add(OperationLog(user_id=user_id, operation=operation, details=details, ip_address=ip_address))
await db.commit()
except Exception:
pass