pf_app/routes
Paul Trowbridge b014f7815a Clone a version's definition without running it
A segment only existed once it had been loaded -- a pf.log entry with
forecast rows behind it -- so there was nowhere to hold "this is the cut I
want, but the dates need changing first", and rebuilding a scenario meant
retyping every segment by hand.

pf.load_plan is the definition on its own, with run_logid naming the log
entry it produced once it has been run. Not in pf.log deliberately: every
row there means a write happened, and unexecuted intent would cost that
table its meaning. The FK is ON DELETE SET NULL, so undoing a load returns
its plan to unrun rather than taking the definition with it.

POST /sources/:id/versions now takes clone_from: settings, version-scoped
layouts, and the segments as plans, running none of them. Plans are read
from the template's own pf.load_plan rows, or derived from its
baseline/reference log entries when it has none -- every version built
before this -- since params already stores the filters and the offset.

Adjustments are not copied in any form. A scale's target was sized against
the rows that were there.

Shift years exists because cloning a definition forward a year is the
reason to clone one, and doing it by hand across eight segments is where
the mistakes come from. Filter values only, and only a bare 20xx: a month
reads "04 - Sep" and a part number that looks like a year must not move.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 10:23:35 -04:00
..
auth.js Read territory at login, and survive having none 2026-09-18 11:52:00 -04:00
layouts.js Make a pivot layout a thing people own and publish 2026-09-19 14:20:04 -04:00
log.js Record what a write ran against, and the statement it ran 2026-09-18 12:19:40 -04:00
operations.js Record what a write ran against, and the statement it ran 2026-09-18 12:19:40 -04:00
plans.js Clone a version's definition without running it 2026-09-21 10:23:35 -04:00
sources.js Make a pivot layout a thing people own and publish 2026-09-19 14:20:04 -04:00
tables.js Read source columns from pg_catalog, not information_schema 2026-09-18 16:12:05 -04:00
versions.js Clone a version's definition without running it 2026-09-21 10:23:35 -04:00