From bf85f11b5f7c5e1d9ce2c5b150978efdbfa016e3 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 28 Apr 2026 19:51:45 -0400 Subject: [PATCH] Expose pf_note/pf_op in forecast data; fix tables list duplicates /data now joins pf.log to surface note text and operation type as pf_note/pf_op so users can pivot/bridge by assumption. Joining at fetch time avoids storing notes per row and keeps edits live. /api/tables joined pg_class by name only with namespace filtered in a separate LEFT JOIN, which cross-producted table names that exist in multiple schemas. Restructured so namespace participates in the join. Co-Authored-By: Claude Opus 4.7 --- routes/operations.js | 7 ++++++- routes/tables.js | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/routes/operations.js b/routes/operations.js index adaefd3..2d32df4 100644 --- a/routes/operations.js +++ b/routes/operations.js @@ -86,7 +86,12 @@ module.exports = function(pool) { client = await pool.connect(); await client.query('BEGIN'); - await client.query(`DECLARE pf_cur CURSOR FOR SELECT * FROM ${tbl}`); + await client.query(` + DECLARE pf_cur CURSOR FOR + SELECT f.*, l.note AS pf_note, l.operation AS pf_op + FROM ${tbl} f + LEFT JOIN pf.log l ON l.id = f.pf_logid + `); // Accumulate rows from the cursor, then emit a single Arrow record batch. // Per-batch tableFromJSON() builds independent dictionaries, which forces the diff --git a/routes/tables.js b/routes/tables.js index 2487645..7c9eca3 100644 --- a/routes/tables.js +++ b/routes/tables.js @@ -12,8 +12,8 @@ module.exports = function(pool) { t.table_name AS tname, c.reltuples::bigint AS row_estimate FROM information_schema.tables t - LEFT JOIN pg_class c ON c.relname = t.table_name - LEFT JOIN pg_namespace n ON n.oid = c.relnamespace AND n.nspname = t.table_schema + LEFT JOIN pg_namespace n ON n.nspname = t.table_schema + LEFT JOIN pg_class c ON c.relname = t.table_name AND c.relnamespace = n.oid WHERE t.table_schema NOT IN ('pg_catalog', 'information_schema', 'pf') ORDER BY t.table_schema, t.table_name `);