Repository navigation
Go to a date years back with one read, and draw long drives the whole way - #109
Merged
Merged
Conversation
… way Going to a day the Drives or Charging list hadn't read yet read every page from today back to it. On a TeslaMate car with 9,365 drives, a day in 2022 took 47 pages and about 24 s of queries, the list redrawing a growing pile of rows after each, and every refresh after that read all 47 again. Picking a day the list doesn't hold now opens the list there: one page, about 0.4 s. Listings take `after` as well as `before`, so a list opened part way back reads the newer pages above it, nearest first, and keeps its place as they arrive; "Back to latest" goes straight to the newest. The Charging calendar offered every month back ten years, since nothing said when charging history starts. A charging-coverage endpoint now does, as drive coverage already did for Drives. A drive's detail read its first 10,000 positions, so with streaming, anything past about an hour drew a route that stopped short (113 of 12,137 drives on one database, the longest 29,922 positions). Both sources now read every position, as do trips, which simplify the route before sending it. The map draws them all; the speed and elevation chart draws an even 2,000, as many as it can show. The web package can now test components in a DOM: Testing Library and jsdom, opted into per file, so the static tests are unchanged. The first test goes to a date 900 days back and checks the list reads two pages, not six. Fixes #108 Fixes #103
The point hovered on the speed and elevation chart was held by the Drives page itself, so each new point redrew the drive card, the calendar, every row of the drive list, and the chart with new props, and rebuilt the route from every position. Now the route map and chart sit in a panel of their own that holds it: the chart is built once per drive, and hovering moves only the marker on the map. The route is built once per drive, too, and the chart draws an even 1,000 points rather than 2,000, still more than one a pixel.
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
On a long Tesla history, going to an old date on the Drives page lagged badly, the Charging calendar offered months back to 2016, and long drives' routes stopped short. This makes going to any date one page read, starts the Charging calendar at the first session, and draws every position of a drive.
Changes
afterparameter (both sources) for this.GET /api/vehicles/:id/charging-coveragegives it one, asdrive-coveragedoes for Drives.evenly(),CHART_POINTS).RoutePanel; hovering moves only the map's marker, and the chart and route are built once per drive.// @vitest-environment jsdom, so existing static tests are unchanged.Testing
evenly()afterpaging and charging coverage on both sources, plus every position of a 25,000-position Tesla drive (704/704 withTEST_DATABASE_URL)Deployment