From 15ab5a3a130b213682d4e10010413c44efd90a1f Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 28 Apr 2026 21:33:32 -0400 Subject: [PATCH] Tag operation result rows with pf_note and pf_op Forecast tables don't carry pf_note; it's joined from pf.log on /data fetch. RETURNING * from scale/recode/clone INSERTs lacks those fields, so rows appended via table.update arrived with pf_note null until a reload re-ran the join. Inject pf_note and pf_op server-side from the request before responding. Co-Authored-By: Claude Opus 4.7 --- routes/operations.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/routes/operations.js b/routes/operations.js index e3d74df..ecf1d9d 100644 --- a/routes/operations.js +++ b/routes/operations.js @@ -254,7 +254,8 @@ module.exports = function(pool) { }); const result = await runSQL(sql); - res.json({ rows: result.rows, rows_affected: result.rows.length }); + const rows = result.rows.map(r => ({ ...r, pf_note: note || null, pf_op: 'scale' })); + res.json({ rows, rows_affected: rows.length }); } catch (err) { console.error(err); res.status(err.status || 500).json({ error: err.message }); @@ -289,7 +290,8 @@ module.exports = function(pool) { }); const result = await runSQL(sql); - res.json({ rows: result.rows, rows_affected: result.rows.length }); + const rows = result.rows.map(r => ({ ...r, pf_note: note || null, pf_op: 'recode' })); + res.json({ rows, rows_affected: rows.length }); } catch (err) { console.error(err); res.status(err.status || 500).json({ error: err.message }); @@ -326,7 +328,8 @@ module.exports = function(pool) { }); const result = await runSQL(sql); - res.json({ rows: result.rows, rows_affected: result.rows.length }); + const rows = result.rows.map(r => ({ ...r, pf_note: note || null, pf_op: 'clone' })); + res.json({ rows, rows_affected: rows.length }); } catch (err) { console.error(err); res.status(err.status || 500).json({ error: err.message });