heatmapStats function

({int activeDays, int maxCount, int total}) heatmapStats(
  1. Map<DateTime, int> daily
)

Summary stats for a date-keyed count map: the busiest day's maxCount, the total across all days, and the number of activeDays with a non-zero count.

An empty map yields (maxCount: 0, total: 0, activeDays: 0). Audited: 2026-06-12 11:26 EDT

Implementation

({int maxCount, int total, int activeDays}) heatmapStats(Map<DateTime, int> daily) {
  int maxCount = 0;
  int total = 0;
  int activeDays = 0;

  // A day is "active" only when its count is positive; a stored 0 does not count.
  for (final int count in daily.values) {
    total += count;
    if (count > 0) {
      activeDays++;
    }
    if (count > maxCount) {
      maxCount = count;
    }
  }
  return (maxCount: maxCount, total: total, activeDays: activeDays);
}