What the dashboard shows, worked out from this device's data: cards rated (crammed included, fresh starts not) and cards written per local day; the streak, up to today or yesterday, rest days counting; the cards falling due per day, but those resting in archived studysets; the study goal's progress in its day or week. The goal, the rest days and the dashboard's arrangement live in the synced settings (payload schema 3). Cards tell when they were made by their UUID v7 ids; reviews report their changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
44 lines
1.2 KiB
Dart
44 lines
1.2 KiB
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<List<ReviewRow>> allReviews() async => [...rows];
|
|
|
|
@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
|
|
Future<void> deleteResets(Set<String> cardIds, DateTime at) async =>
|
|
rows.removeWhere(
|
|
(row) =>
|
|
cardIds.contains(row.cardId) &&
|
|
row.mode == 'reset' &&
|
|
row.reviewedAt == at,
|
|
);
|
|
|
|
@override
|
|
Stream<void> get remoteChanges => const Stream.empty();
|
|
}
|