pf_app/routes
Paul Trowbridge 496642c545 Stamp each log entry with what it did
The change log joined the whole forecast table on every open to total rows
it had just written -- 2.5M rows to report a few thousand, and the Baseline
page's row and value columns paid the same cost again.

The totals go onto pf.log at write time instead. This is not a cache that
can drift: a log entry's forecast rows never change once written, because
only the operation owning the logid inserts them and the only thing that
removes them is undo, which deletes the log row too. measure_cols records
which columns the figures are denominated in, since the value and units
roles can be reassigned in col_meta and the numbers would otherwise quietly
come to mean something else.

Stamping is best-effort and runs after the commit: a failure to record what
happened must not roll back the thing that happened. The loads return their
new log id to make it possible, the adjustments take theirs from the rows
they return, and apply_mode 'each' writes one entry per slice, so it is a
set rather than a single id.

?recount=1 does it the old way and writes back what it finds. Stored totals
cannot drift on their own, but nothing stops someone deleting forecast rows
by hand, and a stored figure has no way to notice -- so there is a way back,
which doubles as the backfill for entries written before the columns
existed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 10:40:39 -04:00
..
auth.js Put the app behind a login 2026-09-14 22:20:25 -04:00
log.js Stamp each log entry with what it did 2026-09-18 10:40:39 -04:00
operations.js Stamp each log entry with what it did 2026-09-18 10:40:39 -04:00
sources.js Keep master data for a dim_group instead of re-deriving it from the source 2026-09-17 00:19:39 -04:00
tables.js Expose pf_note/pf_op in forecast data; fix tables list duplicates 2026-04-28 19:51:45 -04:00
versions.js Put the fallback display names on the version 2026-09-17 23:47:17 -04:00