Skip to content

Commit e5857e2

Browse files
committed
fix(api): alias entrecomillado day en pilot-insights (palabra reservada de PostgreSQL)
La consulta de operadores activos diarios fallaba con syntax error at or near "day" en producción, lo que tumba todo el Promise.all y devuelve 500. El contrato pilot-telemetry-smoke ahora exige el alias entrecomillado.
1 parent 4dffc8d commit e5857e2

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎api/pilot-insights.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default async function handler(request:Request,response:Response){
2929
group by path
3030
order by visits_30d desc,path asc
3131
limit 12`,
32-
sql`select to_char(created_at::date,'YYYY-MM-DD') day,count(distinct operator_id)::int operators
32+
sql`select to_char(created_at::date,'YYYY-MM-DD') "day",count(distinct operator_id)::int operators
3333
from pilot_events
3434
where created_at>=now()-interval '14 days'
3535
group by created_at::date

‎scripts/pilot-telemetry-smoke.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ assert(!/email|fullName|full_name|searchParams/.test(events),'pilot events must
2626
assert(insights.includes("request.method!=='GET'")&&insights.includes('405'),'pilot insights endpoint must be GET-only')
2727
assert(insights.includes("operator.role!=='admin'")&&insights.includes("response.status(403)"),'pilot insights must be admin-only')
2828
assert(insights.includes('from pilot_events')&&insights.includes('from ml_feedback'),'pilot insights must aggregate pilot events and ML feedback')
29+
assert(insights.includes(`'YYYY-MM-DD') "day"`),'pilot insights daily-active query must quote the day alias (reserved word in PostgreSQL)')
2930
assert(!/\b(insert|update|delete)\s+(into|from|[a-z_]+\s+set)\b/i.test(insights),'pilot insights must not mutate data')
3031

3132
// Client beacon: invisible, batched, beacon-first, no-op without sendBeacon.

0 commit comments

Comments
 (0)