#579 Measures: totals in the editor's index and its overview groups (#574)
–
- github
- github/openchronology/timeline-app
- github/openchronology/timeline-app#579
- pull request
- state:merged
Part of #574, part 3 of #570. Stacked on #577 and #578: until they merge, this diff includes their commits. The editor's index keeps its moments' **measure totals** in an augmented tree, and every overview group carries its totals. PostgreSQL and SQLite follow in separate PRs. Durations count at their start in #576. - **`MeasureTree` (`src/measure-tree.ts`):** an AVL tree over distinct times. Each node keeps its own values and its subtree's totals, one exact rational per measure. - Addition is a monoid, so rotations regroup sums without changing them. - A range's totals take O(log n) nodes, and an edit rewrites one path. - **In `TimelineIndex`:** - The tree is built when first read, for a timeline with measures, then kept up to date through the existing `tally` hook: a moved or changed moment is one subtraction and one addition. - A change of declarations rebuilds it. - `measureTotals(lower, upper)` reads a range's totals. - Each overview group carries `totals`: canonical text by name, zeros left out. `coalesceGroups` adds the totals of the groups it merges (`addTotals`). - **Tests:** `test/measure-totals.test.mjs` compares ranges, overview groups at three widths, and coalesced groups against summing by hand. It runs through 2,000 random tree operations and 300 random index edits, and also checks that the tree stays AVL-balanced. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/circagraph/timeline-app/pull/579
Related
- #570 Measures: typed quantities on moments and durations, totalled in every summary
- #574 Measures 3: totals in the summary trees (browser, PostgreSQL, SQLite)
- #576 Measures 5: durations' measures counted where they start
- #577 Measures: declarations, exact values, validation and formats (#572)
- #578 Measures: presentation and parsing per measure, and editor fields (#573)
- #580 Measures: totals in the PostgreSQL moment tree and its overviews (#574)
- #581 Measures: totals in the desktop file's SQLite index (#574)
- Merge pull request #579 from openchronology/feat/574-browser-totals
Open #579 Measures: totals in the editor's index and its overview groups (#574) in the timeline