增加风控列表总数并优化站内提醒
This commit is contained in:
@@ -29,7 +29,7 @@ from enum import StrEnum
|
||||
from types import MappingProxyType
|
||||
from typing import Any, Final, Protocol, cast
|
||||
|
||||
from sqlalchemy import ColumnElement, Select, Table, and_, false, or_, select, true
|
||||
from sqlalchemy import ColumnElement, Select, Table, and_, false, func, or_, select, true
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.errors import ValidationAgentError
|
||||
@@ -135,6 +135,7 @@ class FundPage:
|
||||
limit: int
|
||||
offset: int
|
||||
next_offset: int | None
|
||||
total: int | None = None
|
||||
|
||||
@property
|
||||
def has_more(self) -> bool:
|
||||
@@ -495,6 +496,14 @@ class FundQueryRepository:
|
||||
rows = (await self.session.execute(statement)).mappings().all()
|
||||
has_more = len(rows) > request.limit
|
||||
visible = rows[: request.limit]
|
||||
total = int(
|
||||
await self.session.scalar(
|
||||
select(func.count()).select_from(
|
||||
statement.order_by(None).limit(None).offset(None).subquery()
|
||||
)
|
||||
)
|
||||
or 0
|
||||
)
|
||||
records = tuple(
|
||||
FundRecord(entity=alias, values=MappingProxyType(dict(row))) for row in visible
|
||||
)
|
||||
@@ -504,6 +513,7 @@ class FundQueryRepository:
|
||||
limit=request.limit,
|
||||
offset=request.offset,
|
||||
next_offset=request.offset + request.limit if has_more else None,
|
||||
total=total,
|
||||
)
|
||||
|
||||
def _statement(
|
||||
|
||||
Reference in New Issue
Block a user