Repository navigation
Draw History's routes from every drive, and show where nothing was recorded - #106
Merged
Merged
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.
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.
Past a couple of months the axis stepped by 61 days at most, so a span
of more than a year drew about 18 ticks of month and day, and the same
dates came round again with no year to tell them apart. It now ticks on
the first of a month and, over several years, by year. A January, or a
tick a year or more from the last, reads as its year, and once the ticks
cover a year, other months carry theirs ("Jul ’24").
Labels were also placed without checking they fit, and overlapped at
phone width even on the 7-day default. The axis now measures its label
strip and the labels in the page's own font, and keeps only as many
ticks as clear each other by 8px.
Fixes #101
…corded TeslaMate logs a position every second or so while driving, so a long window was sampled to about 200,000 positions by id before its drives were simplified. The ids are shared between cars and the sample is uneven: over three years of one car, routes strayed more than 50 m from the road for 8.7% of the way, and nine drives came back with no points. Positions are now averaged per drive in SQL, as TeslaMate's own Grafana maps do: every point up to a week, five seconds a point up to a month, fifteen past that. Over the same three years that's 300,000 rows read in about 4 s, 0.2% of the way more than 50 m off, and no drive missing. A minute a point, as TeslaMate's Visited map uses, cut corners by hundreds of metres. Rivian's location points are averaged the same way; a bucket keeps its first bearing, since bearings don't average across north. The response now holds up to 200,000 points rather than 60,000, so three years of a heavily driven car fits without being thinned evenly. The map frames them with a loop rather than spreading them into Math.min, which overflowed the stack. Where the car moved with nothing logged, such as no signal or offline, one drive ends far from where the next one starts. Those stretches are now drawn as a faint dashed line between the two rather than left out, and not joined up as a road the way TeslaMate's Trip map does.
3 of 4 tasks
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.
Also brings in #99 (All time) and #105 (time axis), so History's changes land in one merge and one Docker Hub publish.
Summary
History's map over long periods, for both Rivian and TeslaMate:
point; up to a month, one per 5 seconds; past that, one per 15 seconds. This replaces sampling
TeslaMate's positions by id, which was uneven and dropped some drives entirely.
fits without being thinned evenly.
next one starts, the map draws a faint dashed line between them, rather than leaving a gap or
joining them up like a road.
Three years of a TeslaMate Model Y (12.7M positions):
A minute a point, as TeslaMate's Visited map uses, left 24–30% of the route more than 50m off,
so it isn't used.
Testing
over a short one, TeslaMate's bucketed query, and gaps between drives.
Deployment
Additional Notes
It still polls every minute.