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 <noreply@anthropic.com>
This commit is contained in:
parent
a9ca58a845
commit
bf85f11b5f
@ -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
|
||||
|
||||
@ -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
|
||||
`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user