halkyon/halkyon_learn_flutter/test/support/fake_review_gateway.dart
Tizian 「ティツィアーン」 baace1b6e9
feat(app): reviews know how a card was studied; progress can start afresh
Each review records its mode (ADR 0004, rule 3): front to back, back to
front with a schedule of its own, or crammed outside the schedule. A
card's schedule replays only the reviews of one mode. Resetting progress
appends a 'reset' entry per card, no migration (the column is text):
schedules replay what follows it, and the history stays for the streak
and the heatmap. Reviews are inserted in batches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-01 21:10:05 +02:00

32 lines
906 B
Dart

import 'package:halkyon_learn_flutter/src/feature/study/data/review_gateway.dart';
/// A [ReviewGateway] in memory; ids sort by creation, as UUID v7 ids do.
class FakeReviewGateway() implements ReviewGateway {
var _nextId = 1;
/// Every review stored, in order.
final rows = <ReviewRow>[];
@override
Future<List<ReviewRow>> reviewsOf(Set<String> cardIds) async => [
for (final row in rows)
if (cardIds.contains(row.cardId)) row,
];
@override
Future<void> insert(Iterable<ReviewRow> reviews) async {
for (final review in reviews) {
rows.add((
id: 'review-${(_nextId++).toString().padLeft(4, '0')}',
cardId: review.cardId,
rating: review.rating,
reviewedAt: review.reviewedAt,
durationMs: review.durationMs,
mode: review.mode,
));
}
}
@override
Stream<void> get remoteChanges => const Stream.empty();
}