Measures: totals in the PostgreSQL moment tree and its overviews (#574)
- github
- github/openchronology/timeline-app
- commit
- main
- github/athanclark
Every node of a timeline's moment tree (oc_nodes) keeps the measure totals of its own moments (own_totals) and of its subtree (totals), as JSON maps of exact values by name, zeros left out; NULL is all zero, as in trees built before measures. - avl.mjs keeps them as it keeps event_count: a moment joining or leaving a time adds or takes away its values there, and every rewritten node recomputes its subtree's. A moment whose values change without moving rewrites its path (PersistentTree.adjust); other metadata edits still touch no node. tree.mjs computes them when a whole index is built. - Totals add whatever values are stored, so changing declarations needs no rebuild: renames and removals rewrite values, which the tree follows. - oc_overview_v2 (and its view and fork variants) returns each group's totals, adding (oc_add_totals) the cached totals of the whole subtrees and the own totals of the points it takes; the API's overview groups carry `totals`. Its result type changed, so older versions are dropped first. - Separation views' node tables gain the same columns; forks carry them as row data. Timelines with measures indexed before this (index version 3) are rebuilt once by the migration. - test/measure-totals-postgres.mjs (in CI) checks every overview group's totals at four thresholds against hand sums, after random sparse saves, in a copy reading through to its original, and in a tag separation. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/circagraph/timeline-app/commit/01abf191becd67e1cf808d59876e58b46d2857cd
Related
Open Measures: totals in the PostgreSQL moment tree and its overviews (#574) in the timeline