Fix capture-baseline.ts: postgres-js returns rows directly

db.execute() with drizzle-orm/postgres-js returns rows as an array, not
wrapped in a .rows property (that's node-postgres style). Writing
qpTotals.rows etc. produced undefined and tripped writeFileSync.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Chris Parsons 2026-05-01 06:07:14 +00:00
parent c1df2d8edc
commit 28244c5f43
No known key found for this signature in database

View file

@ -56,9 +56,9 @@ async function main() {
writeFileSync( writeFileSync(
join(OUT_DIR, "qp-totals-pre-phase1.json"), join(OUT_DIR, "qp-totals-pre-phase1.json"),
JSON.stringify(qpTotals.rows, null, 2) JSON.stringify(qpTotals, null, 2)
); );
console.log(` Wrote ${qpTotals.rows.length} rows → qp-totals-pre-phase1.json`); console.log(` Wrote ${qpTotals.length} rows → qp-totals-pre-phase1.json`);
// ─── 2. Capture event_results with qualifying_points_awarded ───────────────── // ─── 2. Capture event_results with qualifying_points_awarded ─────────────────
@ -75,9 +75,9 @@ async function main() {
writeFileSync( writeFileSync(
join(OUT_DIR, "event-results-pre-phase1.json"), join(OUT_DIR, "event-results-pre-phase1.json"),
JSON.stringify(eventResults.rows, null, 2) JSON.stringify(eventResults, null, 2)
); );
console.log(` Wrote ${eventResults.rows.length} rows → event-results-pre-phase1.json`); console.log(` Wrote ${eventResults.length} rows → event-results-pre-phase1.json`);
// ─── 3. Capture participant_surface_elos ────────────────────────────────────── // ─── 3. Capture participant_surface_elos ──────────────────────────────────────
@ -93,9 +93,9 @@ async function main() {
writeFileSync( writeFileSync(
join(OUT_DIR, "surface-elos-pre-phase1.json"), join(OUT_DIR, "surface-elos-pre-phase1.json"),
JSON.stringify(surfaceElos.rows, null, 2) JSON.stringify(surfaceElos, null, 2)
); );
console.log(` Wrote ${surfaceElos.rows.length} rows → surface-elos-pre-phase1.json`); console.log(` Wrote ${surfaceElos.length} rows → surface-elos-pre-phase1.json`);
// ─── 4. Capture simulator output for in-flight qualifying-points seasons ───── // ─── 4. Capture simulator output for in-flight qualifying-points seasons ─────
@ -135,9 +135,9 @@ async function main() {
} }
console.log(`\n✓ Baseline capture complete!`); console.log(`\n✓ Baseline capture complete!`);
console.log(` ${qpTotals.rows.length} QP totals`); console.log(` ${qpTotals.length} QP totals`);
console.log(` ${eventResults.rows.length} event results`); console.log(` ${eventResults.length} event results`);
console.log(` ${surfaceElos.rows.length} surface elo rows`); console.log(` ${surfaceElos.length} surface elo rows`);
console.log(` ${simCount} simulator outputs (non-deterministic)`); console.log(` ${simCount} simulator outputs (non-deterministic)`);
console.log(`\nOutput: ${OUT_DIR}`); console.log(`\nOutput: ${OUT_DIR}`);