fix(stats): recover stale odometer mileage

This commit is contained in:
lingniu
2026-07-20 01:12:09 +08:00
parent 58ab1ff7bb
commit 2ef027c7c2
4 changed files with 123 additions and 1 deletions

View File

@@ -361,6 +361,24 @@ func (w *Writer) AppendWithResult(ctx context.Context, env envelope.FrameEnvelop
}
if w.seenSameMileage(sample) {
result.SamplesSkippedSameMileage++
// A repeated cumulative odometer is usually a harmless duplicate,
// but some upstream platforms keep reporting positions and speed
// while their instrument mileage remains stale for hours. Preserve
// the duplicate evidence and accumulate a speed-backed GPS
// candidate so real movement does not disappear from daily mileage.
if point, ok := GPSMileagePointFromEnvelope(env, identity, w.loc); ok && w.shouldAccumulateGPS(point) {
_, recovered, recoverErr := AccumulateGPSMileage(ctx, w.exec, point)
if recoverErr != nil {
return result, recoverErr
}
w.markGPSAccumulated(point)
if recovered {
result.SamplesWritten++
result.SamplesRecoveredGPSCoordinate++
result.ProjectionsAttempted++
result.ProjectionsWritten++
}
}
continue
}
candidate := SourceMileageSampleFromMetric(sample, identity)