device infos

This commit is contained in:
2026-08-28 15:07:30 +05:30
parent 5723d373b2
commit 69f4f3e909
84 changed files with 4337 additions and 2339 deletions

View File

@@ -89,7 +89,22 @@ abstract final class ServiceDay {
'modifiedon',
'updatedat',
'expected_pickup_time',
'expectedpickuptime',
'createdat',
'createdon',
// ── Last, because it is the app's own guess and not the hub's record ──
//
// When the booking first appeared in this rider's queue, written by
// [WorkRepository] and merged onto the row there. It is the weakest answer
// on this list — a booking the rider's phone met for the first time this
// morning may have been raised last night — so every clock the backend
// actually sends outranks it.
//
// It is on the list because the alternative is worse. A row the backend
// dates with nothing is a row no screen can place, and the observable
// result was yesterday's assignments sitting on Home under a heading that
// says today. An approximate day beats no day.
'assignedat',
];
/// The service day [row] belongs to, or `''` when it carries nothing usable.
@@ -154,6 +169,83 @@ abstract final class ServiceDay {
return day == (now ?? today);
}
/// The rows of [stops] that belong to [now], for a screen that shows the
/// rider's **live** work — Home's run, Deliveries' queue.
///
/// ── Why the work screens needed this and Activity did not ──
///
/// `GET /miler/bookings` returns the rider's whole **open** set, not his day.
/// A booking assigned on Tuesday and never closed comes back on Wednesday and
/// on Thursday, so every screen built from that call was showing a week and
/// calling it today: yesterday's stops inside the kitchen dropdown, inside
/// the trip counts, inside the progress ring and inside the delivery queue.
///
/// Activity already filtered, with [belongsToToday], and that is why the two
/// halves of the app disagreed about the same order. This is the same
/// predicate, applied at the same kind of boundary — the fetch — so that
/// every figure a screen prints is computed from one set rather than each
/// widget filtering for itself. A filter inside a card would have left the
/// counts above it still totalling Tuesday.
///
/// ── The burden of proof is on the row ──
///
/// Undated rows go too, exactly as they do on Activity. They are rare now:
/// `ApiConfig.pickupFromBooking` carries every clock the backend sends
/// instead of dropping them at the adapter, and `WorkRepository` stamps
/// `assignedat` on everything still in front of the rider. A stop with no
/// date at all is one the app has never seen as open work, which is not this
/// morning's assignment.
///
/// ── One safety net, and it is deliberately narrow ──
///
/// If the day came back with rows and **not one of them** can be dated, that
/// is not a stale queue — it is the app having lost the ability to date
/// anything at all, and the answer to that is not to show a rider an empty
/// screen while his hub believes he has twenty stops. That case keeps
/// everything and says so in the log. One undated row among dated ones is a
/// data defect and is dropped; *every* row undated is a broken build, and
/// blanking the screen would hide it behind something that reads like good
/// news.
///
/// [where] names the caller in the log line, so two screens filtering the
/// same day are told apart. Nothing is deleted anywhere: this is a view
/// filter, and both local stores and the backend keep every record they had.
static List<Map<String, dynamic>> onlyToday(
List<Map<String, dynamic>> stops, {
String? now,
String where = 'DAY',
}) {
if (stops.isEmpty) return stops;
final day = now ?? today;
final kept = <Map<String, dynamic>>[];
var undated = 0;
for (final s in stops) {
if (of(s).isEmpty) {
undated++;
logUndated(s);
continue;
}
if (belongsToToday(s, now: day)) kept.add(s);
}
if (undated == stops.length) {
debugPrint(
'[$where] $day — not one of ${stops.length} stops carries a date. '
'Showing the lot rather than an empty day; check the adapter.',
);
return stops;
}
if (kept.length != stops.length) {
debugPrint(
'[$where] $day — kept ${kept.length} of ${stops.length} stops'
'${undated > 0 ? ' ($undated undated)' : ''}',
);
}
return kept;
}
/// The standard [belongsToToday] undated reporter: names the row, says which
/// fields were looked for, and stays out of release logs.
///