basquetWi + New ticket
mars MARS-68

Audit Next.js/Node compute that should be pushed to Postgres (aggregations/filters/joins done in JS that belong in SQL or a view)

Done normal unassigned

Questions

No questions.

Activity

  • wi-cli-venus created · 2026-06-09
  • wi-cli-venus commented · 2026-06-12
    Audit complete (db02-mars-cc, 2026-06-12). No correctness bugs. 8 findings ranked by impact: HIGH: #1 N+1: resolveCanonicalTcmTeachers per import row (administrar-actions.ts:1305) — 200-student import fires 200 queries instead of 3. Fix: batch all unique comisionIds before the loop. Coder-only change. #2 N+1: sequential logEvent per audit row (administrar-actions.ts:1328-1355) — 200+ sequential INSERTs after import. Fix: new logEvents() batch helper. Coder + DB review. MEDIUM: #3 Roster role-split in JS (comisiones/[id]/page.tsx:143-147) — 4x scan over already-fetched roster. Fix: structured return from getComisionRoster. Coder-only. #4 Linear .find() for periodoId in import loop (administrar-actions.ts:1294) — trivial, fix with comisionById Map. Coder-only, bundle with #1. #5 Orphan-student Set dedup (comisiones/[id]/page.tsx:153-158) — stems from vComisionStudentsByJtp UNION emitting a NULL-jtp row for ayudante-only students. View fix: add AND (sa.assignedTeacherUserId IS NOT NULL OR sa.ayudanteUserId IS NULL) to Branch 1 WHERE clause. DB-lane pre-fix (no app code change needed; JS dedup becomes a no-op but stays harmless). Confirmed safe. LOW: #6 TCM allCount JS reduce (student-assignment-tcm.ts:96) — 2-row dataset, trivial. #7 weekly-kpi.ts .find()/.filter()/.reduce() on pre-aggregated audience — small dataset, no action urgency. #8 alumnos-table.tsx client-side comision dedup for dropdown — appropriate for client-filtered table. Dispatch order: #1+#4 (coder, one PR, wait for tree to free) → #2 (coder + new logEvents helper) → #5 (db lane view fix, greenlit by PM, can run now) → #3 → #6-8 backlog. Findings file: mars/db/mars-68-compute-pushdown-findings.md
  • wi-cli-venus statusChanged · 2026-06-12
    Audit done — #5 view fix greenlit (db lane); #1+#4 coder dispatch pending tree free
  • wi-cli-venus commented · 2026-06-12
    #5 (a) DB view fix applied and verified (vComisionStudentsByJtp Branch-1 NULL-jtp suppression for ayudante-only students). Schema docs re-exported, riding coder02's next push. #5 (b) remaining: remove now-no-op JS orphan-dedup Set in comisiones/[id]/page.tsx:153-158 — deferred as low-pri cleanup, no correctness impact (Set is a no-op post view fix).
  • wi-cli-venus commented · 4w ago
    #1/#2/#4 shipped + audit-clean (97402f7 v2.27.2, 0e47975 v2.27.3). #3 (vComisionStudentsByJtp reshape, drop JS orphan-dedup) opened with db-mars-cc as Class-A. #6 LOW backlog. #7/#8 unchanged backlog. Parent stays inProgress pending #3 cutover.
  • wi-cli-venus completed · 4w ago
    All findings dispositioned: #1 N+1 batch-resolve + #4 linear-find→Map shipped 97402f7/v2.27.2; #2 batch logEvents shipped 0e47975/v2.27.3, all audit-clean; #3 closed non-defect (db+coder joint finding: view already prevents the described double-emission, JS filter is harmless defensive code guarding a view-prevented state, reshape would break intentional dual-teacher fan-out); #5 view fix shipped earlier; #6 backlog LOW; #7/#8 backlog no-urgency.
task
2026-06-09 by wi-cli-venus
4w ago
2026-07-15 08:26