statusCounts method

Map<String, int> statusCounts()

How many tracked records are in each status, how many of those are fetching, and how many remembered queries are stale or unmounted. Counters only: nothing is copied out of the cache. Every count is zero while the cache is not answering.

Implementation

Map<String, int> statusCounts() => _ask((c) {
  final counts = _zeroStatuses();

  for (final record in c.trackedRecords()) {
    counts[record.status] = (counts[record.status] ?? 0) + 1;
    if (record.fetching) counts['fetching'] = counts['fetching']! + 1;
  }

  for (final query in c.queries()) {
    if (query.stale) counts['stale'] = counts['stale']! + 1;
    if (query.mounts == 0) counts['unmounted'] = counts['unmounted']! + 1;
  }

  return counts;
}, _zeroStatuses());