fix(awooop): type dossier run filter
This commit is contained in:
@@ -84,9 +84,21 @@ async def fetch_channel_event_dossier(
|
||||
|
||||
effective_project_id = project_id or "awoooi"
|
||||
safe_limit = max(1, min(limit, _MAX_DOSSIER_EVENTS))
|
||||
where_clauses = ["project_id = :project_id"]
|
||||
params: dict[str, Any] = {
|
||||
"project_id": effective_project_id,
|
||||
"limit": safe_limit,
|
||||
}
|
||||
if run_id is not None:
|
||||
where_clauses.append("run_id = CAST(:run_id AS uuid)")
|
||||
params["run_id"] = str(run_id)
|
||||
if provider_event_id:
|
||||
where_clauses.append("provider_event_id = :provider_event_id")
|
||||
params["provider_event_id"] = provider_event_id
|
||||
|
||||
async with get_db_context(effective_project_id) as db:
|
||||
result = await db.execute(
|
||||
text("""
|
||||
text(f"""
|
||||
SELECT
|
||||
event_id,
|
||||
project_id,
|
||||
@@ -101,18 +113,11 @@ async def fetch_channel_event_dossier(
|
||||
provider_ts,
|
||||
received_at
|
||||
FROM awooop_conversation_event
|
||||
WHERE project_id = :project_id
|
||||
AND (:run_id IS NULL OR run_id = :run_id)
|
||||
AND (:provider_event_id IS NULL OR provider_event_id = :provider_event_id)
|
||||
WHERE {" AND ".join(where_clauses)}
|
||||
ORDER BY received_at ASC
|
||||
LIMIT :limit
|
||||
"""),
|
||||
{
|
||||
"project_id": effective_project_id,
|
||||
"run_id": run_id,
|
||||
"provider_event_id": provider_event_id,
|
||||
"limit": safe_limit,
|
||||
},
|
||||
params,
|
||||
)
|
||||
rows = [dict(row) for row in result.mappings().all()]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user