upsert method

void upsert({
  1. required String categoryId,
  2. required int totalCheckpoints,
  3. required int completedCheckpoints,
  4. DateTime? updatedAt,
})

Implementation

void upsert({
  required String categoryId,
  required int totalCheckpoints,
  required int completedCheckpoints,
  DateTime? updatedAt,
}) {
  final normalizedTotal = totalCheckpoints < 0 ? 0 : totalCheckpoints;
  _totalCheckpointsByCategoryId[categoryId] = normalizedTotal;
  _entriesByCategoryId[categoryId] = CategoryProgressEntry(
    totalCheckpoints: normalizedTotal,
    completedCheckpoints: completedCheckpoints,
    updatedAt: updatedAt ?? DateTime.now(),
  );
  revision.value++;
}