Repository navigation
Add an all-time period to History - #99
Merged
2 commits merged intoNov 9, 2026
Merged
2 commits merged into
2 commits merged into
Conversation
History's longest period is 12 months, so a longer record cannot be seen at all. This adds an "All time" period whose window runs from the first drive to now, and nothing else: the window comes from the coverage the page already loads, and a fixed-length-less period is drawn six hours a point and a month a bar past two years. Two things had to move for it. The queries that key on the period alone wait for the window, or an empty answer would be cached under the key the view then uses; and neither prefetch loads all time, whose window is the whole history. If the coverage read fails with nothing loaded, the page says so above the cards with a retry.
This was referenced Nov 8, 2026
3 tasks done
All time is the whole history, so polling it every minute re-read every drive, session, span and location point each time. Its queries now load when the period is picked and stay fresh for five minutes, so switching away and straight back doesn't load it again. The map's frame and the timeline's value range spread every point into Math.min and Math.max, and a long history has more points than a call takes arguments: the page threw "Maximum call stack size exceeded". Both now use a loop.
Owner
|
Thanks for this. I added one commit on top, 3a22241:
The notes about the 5,000-row limit are out of date: #104 removed it. The axis labels are fixed in #105 and the long-range map in #106. All three land together. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
History's max time period is currently 12 months. This adds an All time period, whose window runs
from the first drive to now.
Changes
options.ts— anallperiod (bucket: '6h', no fixed length) withisAllTime(), andprefetchRanges(), which leaves it out of what loads ahead. Six hours a point, because day buckets arecut in UTC and would each land on the wrong local day.
history.ts—rangeWindow()takes the first drive, so a period of no fixed length starts there.Until it is known the window is empty; a
sincethat does not parse, or one from ahead of us, istreated as unknown rather than throwing while the page renders.
distanceByPeriod()gains a calendarmonth.
HistoryPage.tsx— reads the first drive before computing the window, and waits for it beforeasking anything: the three queries that key on the period alone would otherwise cache an empty answer
under the key the view then uses, and the drives and sessions would ask for a zero-width window. If
that read fails with nothing loaded, the page says so above the cards, with a retry. The header reads
"All time".
SummaryCard.tsx— a bar a month past two years, chosen from the window's length rather than theperiod's name, and month labels that carry the year.
Timeline.tsx— its chart waits for the window before loading.Testing
rangeWindowfor all time with, without, with an unparseable firstdrive and with one from ahead of us; month buckets including a quiet month between two drives;
prefetchRangesin both directions, and that all time ends the period list.without
TEST_DATABASE_URL.format:check,typecheck,lintandbuildclean.Deployment
Screenshots
Demo mode (
MOCK_RIVIAN=1), whose history starts six days ago.The period dropdown, with the new entry last:
History under All time — the header and the period selector both read it, and the figures are the
seven days', since the window starts at the first drive:
The vehicle-state strip and the battery line cover only the running session, because the demo scene seeds
drives and charges but records state live.
The month bars, which need more than two years and so cannot be reached from the committed scene: a
local database seeded with three years of synthetic drives. Its timeline axis repeats labels at this
range, which predates this change. No real vehicle data:
Additional Notes
car's first drive.
useDriveCoverageis the anchor the page already had forthe energy ledger; a vehicle whose charging predates its first drive has that charging outside the
window.
/drivesand/charging-sessionseach return at most5,000 rows when given a window, and they keep the newest. Past that, an all-time summary undercounts and
the earliest bars draw empty. Unchanged by this PR — the same cap applies to 12 months — but all time
reaches it sooner.
/vehicles/:id/locationsselects every point in thewindow and thins afterwards, and
/historyloads every change before bucketing, sobucketbounds theresponse and not the read. TeslaMate does the bucketing and the row cap in SQL, so this is Rivian's
path.
/charge-spansand/state-spansread the same way, but consecutive changes collapse into spans,so far fewer rows come back. I have not measured an all-time window against a multi-year history; mine
is nine days old.
per metric request against 1,825. Response size only — the read is the same either way.
/historytakes an unboundedfromand already accepted6hand1dbuckets.