fix(stats): enforce latest source endpoint only for projected daily mileage
This commit is contained in:
@@ -66,3 +66,17 @@ cd go/vehicle-gateway && go test ./internal/stats -run TestProjectDailyMileageSe
|
||||
cd go/vehicle-gateway && go test ./internal/stats -count=1
|
||||
# PASS: lingniu-vehicle-ingest/go/vehicle-gateway/internal/stats
|
||||
```
|
||||
|
||||
## Fix (reviewer findings #2)
|
||||
|
||||
Corrected the remaining `projectDailyMileageSQL` contract issue so `trusted_source_endpoint` uses only `vehicle_data_source.latest_source_endpoint`:
|
||||
|
||||
- In `go/vehicle-gateway/internal/stats/source_mileage.go`, changed the projection from:
|
||||
`COALESCE(NULLIF(ds.latest_source_endpoint, ''), s.source_endpoint)`
|
||||
to:
|
||||
`ds.latest_source_endpoint`.
|
||||
- In `go/vehicle-gateway/internal/stats/source_mileage_test.go`, extended `TestProjectDailyMileageSelectsCandidateAndMarksSource` assertions to:
|
||||
- require `ds.latest_source_endpoint` is selected, and
|
||||
- explicitly verify no fallback expression using `s.source_endpoint` remains.
|
||||
|
||||
This enforces the strict source-of-truth rule that endpoint data for final projection must come from latest connection metadata only, even when it is null/empty.
|
||||
|
||||
Reference in New Issue
Block a user