Repository navigation
feat: show the range on a full battery, the distance per charge and the usual charge in statistics - #779
Open
arthur-lzrs wants to merge 1 commit into
Open
feat: show the range on a full battery, the distance per charge and the usual charge in statistics#779arthur-lzrs wants to merge 1 commit into
arthur-lzrs wants to merge 1 commit into
Conversation
…he usual charge in statistics The charge history already lists each charge with its odometer and battery levels, and what was driven since the one before. Nothing added those up into the figures a driver asks: how far does the car really go on a full battery, how far between charges, and from what level to what level does it usually charge. Three insight cards on the Statistics page, from the charges of the period (the charge-sessions the page for the charge history already reads, one more request for a car that can plug in): - Range on a full battery (BEV only, as a hybrid's kilometres include petrol): the kilometres between two charges per percent of battery used between them, added up over the pairs, times 100. Pairs under 10 km or 10 points are too short to read, and a pair more than twice off the middle kilometres-per-percent is left out: a charge no poll caught between two reported ones makes a pair that spans two charges, with the battery having gained in the middle. - Distance per charge: the middle value of the distances between charges, so that same unseen charge, which makes one long pair, does not pull it up. A hop under 5 km is a split charge. - Typical charge: the average level the finished charges started from and ended at. Each needs at least three charges, and none is shown without. The logic is in utils/chargeStatistics, the cards are in the existing insight list (appended, so a layout saved before keeps its order and gets them last), and each has an info text saying how it is worked out, in every locale. A charge list that cannot be read leaves the rest of the page as it was. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
The charge history lists every charge with its odometer and battery levels, and what was driven since the one before. Nothing added those up into the figures a driver asks about: how far does my car really go on a full battery? how far between charges? from what level to what level do I usually charge?
Three new insight cards on the Statistics page, from the charges of the selected period:
42% → 80%.Each needs at least three charges, so none is shown on a car that has not charged that often in the period. Each has an info text that says how it is worked out.
How it works
utils/chargeStatistics.tshas the logic:chargePairspairs each charge with the next (distance from the odometers, battery used from the levels), and the three figures are computed from the pairs. The pairs are built from the same figures the charge history'ssincePreviousChargereads from the same sessions (the odometer and the battery levels of each charge).README.mdhas the three rows in the insight table.Type of Change
Related Issues
None.
How it was tested
chargeStatistics(pairing in any order, a charge still going, missing levels, a level that went up, a pair that went backwards; the middle value with an unseen charge; the range with outliers, short pairs and too few; the habit).StatisticsViewtests: what the page asks for and of which cars, the three cards on a BEV and two on a plug-in hybrid, none with too few charges, and the page still showing when the charges cannot be read.Notes for review
nl,esandpt-PTis my own draft, so a native check is welcome.MIN_PAIRS, the 10 km / 10 points, the factor of two, the 5 km hop) are constants at the top ofchargeStatistics.ts, easy to tune.Checklist
pnpm checkinfrontend/(frontend only: the .NET side is untouched, sodotnet testanddotnet formatwere not run)feat: ...,fix(frontend): ...)ITripRepository): done in the demo too, with a step inTripRepositoryContractTests(not applicable)documentation/openapi.jsonis committed (not applicable, the API did not change)src/GarageStack.Data/Demo/(the demo's charge history already has what the cards read)frontend/src/locales/unraid/garagestack.xmlchanged: synced tojoszz/unraid-community-appsafter merge (not applicable, it did not change)🤖 Generated with Claude Code