1
This commit is contained in:
@@ -5,7 +5,7 @@ from datetime import datetime, timedelta, timezone, date
|
||||
from typing import Any
|
||||
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy import func, select
|
||||
from sqlalchemy import and_, func, select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.config import settings
|
||||
@@ -507,6 +507,9 @@ async def list_async_generation_tasks(
|
||||
page: int,
|
||||
page_size: int,
|
||||
is_admin: bool = False,
|
||||
engine_id: str | None = None,
|
||||
created_start: datetime | None = None,
|
||||
created_end: datetime | None = None,
|
||||
):
|
||||
if is_admin:
|
||||
query = (
|
||||
@@ -533,6 +536,18 @@ async def list_async_generation_tasks(
|
||||
if status:
|
||||
query = query.where(ChatGenerationTask.status == status)
|
||||
|
||||
if engine_id:
|
||||
query = query.where(ChatGenerationTask.engine_id == engine_id)
|
||||
|
||||
if created_start is not None or created_end is not None:
|
||||
range_filters = []
|
||||
if created_start is not None:
|
||||
range_filters.append(ChatGenerationTask.created_at >= created_start)
|
||||
if created_end is not None:
|
||||
range_filters.append(ChatGenerationTask.created_at <= created_end)
|
||||
if range_filters:
|
||||
query = query.where(and_(*range_filters))
|
||||
|
||||
count_query = select(func.count()).select_from(query.subquery())
|
||||
total = (await db.execute(count_query)).scalar_one()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user