Cars: log what charging costs, and drag the provider readings
Three things, all on a car's page. A Charging cost tab, which is the Fuel cost tab written for an electric car: charges in kWh, consumption in kWh/100km beside km per kWh, cost per km and price per kWh, and the same summary panel over the whole history. It keeps the reference-point method too, and has to — a session records the energy that went in, not what was left in the battery, so a given number of kWh only maps to a distance between two charges that ended at the same state. A charge to the car's usual full point plays the part of the full tank; partial charges still count towards the cost and roll into the next full one; and a charge taken without logging it leaves its window uncomputed rather than reporting an implausibly good figure. Sessions live in their own collection, the figures are derived on read like the fuel ones, and logging a charge advances the odometer exactly as a refill does. The tab switches off from the gear like every other, so a petrol car need never see it. The headline readings on the connected-service tab now drag into any order, saved on drop. Stored on the car as metricOrder, like the Information rows, rather than per device the way the collapsed cards are: an arrangement is something everyone the car is shared with should see, where a folded card is one browser's reading habit. Only what the provider reported can be arranged, so a reading that turns up later joins the end rather than displacing the arrangement. Fuel is now Fuel cost, tab and heading, which is what the tab has always been about and what pairs it with Charging cost. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
2b6da642ad
commit
6191160f14
@@ -85,6 +85,13 @@
|
||||
// GET /api/fuel-entries/{id} PATCH /api/fuel-entries/{id}
|
||||
// DELETE /api/fuel-entries/{id}
|
||||
//
|
||||
// # charging tracking (EV counterpart of fuel; efficiency derived on read)
|
||||
// GET /api/cars/{id}/charging-sessions
|
||||
// GET /api/cars/{id}/charging-stats
|
||||
// GET /api/charging-sessions POST /api/charging-sessions
|
||||
// GET /api/charging-sessions/{id} PATCH /api/charging-sessions/{id}
|
||||
// DELETE /api/charging-sessions/{id}
|
||||
//
|
||||
// # maintenance log (workshop visits + repairs; distinct from service records)
|
||||
// GET /api/cars/{id}/maintenance
|
||||
// GET /api/maintenance POST /api/maintenance
|
||||
@@ -99,7 +106,7 @@
|
||||
//
|
||||
// # attachments — one optional file per record, same three verbs everywhere.
|
||||
// # {records} is car-documents | service-records | technical-checks | maintenance
|
||||
// # | fuel-entries | parts
|
||||
// # | fuel-entries | charging-sessions | parts
|
||||
// POST /api/{records}/{id}/file
|
||||
// GET /api/{records}/{id}/file
|
||||
// DELETE /api/{records}/{id}/file
|
||||
@@ -136,6 +143,7 @@ const (
|
||||
colShares = "car_shares"
|
||||
colOrgs = "organizations"
|
||||
colFuel = "fuel_entries"
|
||||
colCharging = "charging_sessions"
|
||||
colMaintenance = "maintenance_entries"
|
||||
colDocuments = "car_documents"
|
||||
colReminders = "reminders"
|
||||
@@ -360,6 +368,8 @@ func (s *Server) Handler() http.Handler {
|
||||
mux.HandleFunc("GET /api/cars/{id}/parts", s.listCarParts)
|
||||
mux.HandleFunc("GET /api/cars/{id}/fuel-entries", s.listCarFuelEntries)
|
||||
mux.HandleFunc("GET /api/cars/{id}/fuel-stats", s.listCarFuelStats)
|
||||
mux.HandleFunc("GET /api/cars/{id}/charging-sessions", s.listCarChargingSessions)
|
||||
mux.HandleFunc("GET /api/cars/{id}/charging-stats", s.listCarChargingStats)
|
||||
mux.HandleFunc("GET /api/cars/{id}/maintenance", s.listCarMaintenance)
|
||||
mux.HandleFunc("GET /api/cars/{id}/documents", s.listCarDocuments)
|
||||
mux.HandleFunc("GET /api/cars/{id}/reminders", s.listCarReminders)
|
||||
@@ -398,6 +408,13 @@ func (s *Server) Handler() http.Handler {
|
||||
mux.HandleFunc("PATCH /api/fuel-entries/{id}", s.updateFuelEntry)
|
||||
mux.HandleFunc("DELETE /api/fuel-entries/{id}", s.deleteFuelEntry)
|
||||
|
||||
// Charging sessions.
|
||||
mux.HandleFunc("GET /api/charging-sessions", s.listChargingSessions)
|
||||
mux.HandleFunc("POST /api/charging-sessions", s.createChargingSession)
|
||||
mux.HandleFunc("GET /api/charging-sessions/{id}", s.getChargingSession)
|
||||
mux.HandleFunc("PATCH /api/charging-sessions/{id}", s.updateChargingSession)
|
||||
mux.HandleFunc("DELETE /api/charging-sessions/{id}", s.deleteChargingSession)
|
||||
|
||||
// Maintenance log.
|
||||
mux.HandleFunc("GET /api/maintenance", s.listMaintenance)
|
||||
mux.HandleFunc("POST /api/maintenance", s.createMaintenance)
|
||||
@@ -429,6 +446,7 @@ func (s *Server) Handler() http.Handler {
|
||||
s.attachmentRoutes(mux, "/api/technical-checks", colTechnicalChecks, s.getTechnicalCheck)
|
||||
s.attachmentRoutes(mux, "/api/maintenance", colMaintenance, s.getMaintenance)
|
||||
s.attachmentRoutes(mux, "/api/fuel-entries", colFuel, s.getFuelEntry)
|
||||
s.attachmentRoutes(mux, "/api/charging-sessions", colCharging, s.getChargingSession)
|
||||
s.attachmentRoutes(mux, "/api/parts", colParts, s.getPart)
|
||||
|
||||
return s.withMiddleware(mux)
|
||||
|
||||
Reference in New Issue
Block a user