perf: narrow optimization_features select in getTraceData, fix pre-existing type errors

- optimization_features.findFirst: select only 12 consumed fields instead
  of all 30+ columns (skips optimizations_raw, speedup_ratio,
  experiment_metadata, original_runtime, approval_*, slack_message_ts, etc.)
- optimization_errors.findMany: add id and created_at back to select
  (fixes 5 pre-existing TS2339 errors in page.tsx, trace page, and
  llm-export route that accessed these fields on narrowed types)
This commit is contained in:
Kevin Turcios 2026-04-11 03:57:42 -05:00
parent 6f9e81a690
commit 7221d44858

View file

@ -26,14 +26,30 @@ export async function getTraceData(tracePrefix: string) {
where: { trace_id: { startsWith: tracePrefix } },
orderBy: { created_at: "asc" },
select: {
id: true,
error_type: true,
severity: true,
error_message: true,
context: true,
created_at: true,
},
}),
prisma.optimization_features.findFirst({
where: { trace_id: { startsWith: tracePrefix } },
select: {
original_code: true,
optimizations_post: true,
explanations_post: true,
optimizations_origin: true,
ranking: true,
pull_request: true,
metadata: true,
test_framework: true,
generated_test: true,
instrumented_generated_test: true,
instrumented_perf_test: true,
dependency_code: true,
},
}),
prisma.optimization_events.findFirst({
where: { trace_id: { startsWith: tracePrefix } },