production
This commit is contained in:
@@ -108,9 +108,22 @@ class StopCompliance {
|
||||
return StopCompliance(
|
||||
onTime: onTime,
|
||||
lateBy: lateSeconds == null ? null : Duration(seconds: lateSeconds),
|
||||
// `riderkms` is the backend's own name for the distance ridden, so a row
|
||||
// that came straight from the API reads without a stamp.
|
||||
actualKm: _double(m['actualkm']) ?? _double(stop['riderkms']),
|
||||
// ── Three spellings, because the app writes two of them itself ──
|
||||
//
|
||||
// `compliance.actualkm` is the contract's. `riderkms` is the backend's
|
||||
// own name on a booking row that came straight from the API. And
|
||||
// `actualkms` is what **this app** posts on the arrival and pickup writes
|
||||
// (`PickupsController`), so it is the key on any record that was stamped
|
||||
// locally before the queue caught up.
|
||||
//
|
||||
// Reading only the first two meant a stop the rider had just finished
|
||||
// reported no distance at all until a poll replaced the row — which is
|
||||
// most of the rows on Activity for most of a shift, and it is why the
|
||||
// day's total read zero.
|
||||
actualKm:
|
||||
_double(m['actualkm']) ??
|
||||
_double(stop['riderkms']) ??
|
||||
_double(stop['actualkms']),
|
||||
plannedKm: _double(m['plannedkm']) ?? _double(stop['kms']),
|
||||
);
|
||||
}
|
||||
@@ -131,7 +144,14 @@ class StopCompliance {
|
||||
|
||||
static double? _double(dynamic v) {
|
||||
if (v == null) return null;
|
||||
if (v is num) return v.toDouble();
|
||||
// ── Zero is not a measurement, whichever type it arrives as ──
|
||||
//
|
||||
// A numeric `0` returned `0.0` here while the string `"0"` returned null,
|
||||
// so the same absent distance resolved two different ways depending on
|
||||
// whether the row came off JSON or off a locally stamped map. Callers all
|
||||
// guard with `> 0`, so nothing was visibly wrong — which is precisely why
|
||||
// it would have gone on being inconsistent.
|
||||
if (v is num) return v == 0 ? null : v.toDouble();
|
||||
final parsed = double.tryParse(
|
||||
v.toString().replaceAll(RegExp(r'[^0-9.\-]'), ''),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user