Ongoing durations: an end that is "now"
Free, open-source timeline editor for exact dates at any scale.
Brought to you by:
athanclark
Originally created by: athanclark
Part of [#533]. Open work items (an assigned issue, a card in progress, a shift not yet clocked out), and history such as "2022–present", need a duration whose end is now, still moving, until it is closed.
A third kind of duration endpoint, beside a fixed time and {"moment": id}:
{ "id": "issue-412", "start": "1762560000", "end": { "ongoing": true }, "metadata": { "title": "Fix the login loop" } }
end may be ongoing.durationTree, the server's AVL index, native-store/src/intervals.rs), so cached extents never go stale. It is cut off at the current time only when a band is resolved for a window..ochx, .och (SQLite), the HTTP API and OpenAPI schema, merges and history, and export and conversion (och-convert).docs/durations.md describes them.
Originally posted by: athanclark
Design
The browser's interval tree is rebuilt in memory, but the server's (
oc_duration_nodes, viaserver/avl.mjs) and the native store's (native-store/src/intervals.rs) are persisted as exact rationals. PostgreSQL computes windows and summaries over them in SQL, through forks and saved views. Neither format has an "infinity" or a clock, so "now" cannot be stored in them.Stored as a placeholder. An ongoing duration stays a row of the tree, as a zero-length band at its start. Its definition carries
"end": {"ongoing": true}. Storage, forks, history, lookup by ID and listing therefore need no schema change.Resolved at query time. Each window query also reads the timeline's ongoing durations, through a partial index on the definition and with a per-timeline cap. It resolves each against "now", as
last = max(start, now), then:"Now" is the server's clock for server queries and the page's clock in the browser. It is mapped through the Gregorian preset: stored = Unix seconds × scale + origin.
Stages
.ochx. The server refuses ongoing ends until stage 2.och-convert.