audit-fix: загрузка пользователя в журнале аудита
This commit is contained in:
parent
bf3896f2f0
commit
8e07135a16
@ -49,8 +49,8 @@ class AppUser(Base):
|
|||||||
# back_populates="updater",
|
# back_populates="updater",
|
||||||
# foreign_keys="RfProjectReport.updated_by",
|
# foreign_keys="RfProjectReport.updated_by",
|
||||||
# )
|
# )
|
||||||
# audit_logs: Mapped[list["AuditLog"]] = relationship( # type: ignore
|
audit_logs: Mapped[list["AuditLog"]] = relationship( # type: ignore
|
||||||
# "AuditLog", back_populates="user"
|
"AuditLog", back_populates="user"
|
||||||
# )
|
)
|
||||||
user_orgs: Mapped[list["UserOrg"]] = relationship("UserOrg", back_populates="user")
|
user_orgs: Mapped[list["UserOrg"]] = relationship("UserOrg", back_populates="user")
|
||||||
org_units: Mapped[list["OrgUnit"]] = relationship("OrgUnit", secondary="v3.user_org", viewonly=True)
|
org_units: Mapped[list["OrgUnit"]] = relationship("OrgUnit", secondary="v3.user_org", viewonly=True)
|
||||||
|
|||||||
@ -55,9 +55,9 @@ class AuditLog(Base):
|
|||||||
event_type: Mapped[str] = mapped_column(String)
|
event_type: Mapped[str] = mapped_column(String)
|
||||||
event_data: Mapped[dict | None] = mapped_column(JSON)
|
event_data: Mapped[dict | None] = mapped_column(JSON)
|
||||||
|
|
||||||
# user: Mapped["AppUser | None"] = relationship(
|
user: Mapped["AppUser | None"] = relationship(
|
||||||
# "AppUser", back_populates="audit_logs"
|
"AppUser", back_populates="audit_logs"
|
||||||
# )
|
)
|
||||||
# org_unit: Mapped["OrgUnit | None"] = relationship(
|
# org_unit: Mapped["OrgUnit | None"] = relationship(
|
||||||
# "OrgUnit", back_populates="audit_logs"
|
# "OrgUnit", back_populates="audit_logs"
|
||||||
# )
|
# )
|
||||||
|
|||||||
@ -4,6 +4,8 @@ from typing import Iterable, Optional
|
|||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from sqlalchemy.sql.functions import func
|
from sqlalchemy.sql.functions import func
|
||||||
|
from sqlalchemy.orm import joinedload
|
||||||
|
|
||||||
# from sqlalchemy.orm import selectinload
|
# from sqlalchemy.orm import selectinload
|
||||||
|
|
||||||
# from app.domain.models import AuditLog
|
# from app.domain.models import AuditLog
|
||||||
@ -66,6 +68,8 @@ class AuditLogRepository:
|
|||||||
query = query.where(AuditLog.event_dt <= date_to)
|
query = query.where(AuditLog.event_dt <= date_to)
|
||||||
query_count = query_count.where(AuditLog.event_dt <= date_to)
|
query_count = query_count.where(AuditLog.event_dt <= date_to)
|
||||||
|
|
||||||
|
query = query.options(joinedload(AuditLog.user))
|
||||||
|
|
||||||
query = query.order_by(AuditLog.event_dt.desc())
|
query = query.order_by(AuditLog.event_dt.desc())
|
||||||
|
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user