reclaim/app/lib/data/repository.dart
flemming-it 852f9da703 fix(ui): sort evaluations by SKM €/year descending
Repository.list() now hands the UI a list sorted by the harm
proxy (Studie §6 SKM-€/Jahr). Most-harmful first, deterministic
across launches and across mock-vs-hub repositories. Removes
the perceived non-determinism in the Norms list and gives the
heatmap chip-wrap a politically meaningful first row.

Signed-off-by: flemming-it <sf@flemming.it>
2026-06-18 13:18:30 +02:00

47 lines
1.4 KiB
Dart

import 'models.dart';
import 'fixtures.dart';
/// Repository abstraction for evaluations.
///
/// Phase 0 ships exactly one implementation: [MockRepository],
/// backed by [Fixtures]. The live implementation (gRPC against a
/// running `chain serve`) lands in Phase 0 week 1 — its API will
/// match this interface so no UI change is needed.
abstract class EvaluationRepository {
Future<List<Evaluation>> list();
Future<Evaluation?> byEli(String eli);
String get mode;
String get hubLabel;
}
/// In-memory, no-network implementation. Marks itself clearly so
/// the UI shows a "demo mode" badge.
class MockRepository implements EvaluationRepository {
const MockRepository();
/// Sorted copy of [Fixtures.evaluations], most-harmful first
/// (Studie §6 SKM-€/Jahr as harm proxy). The sort is in
/// repository.list() rather than the fixture declaration so
/// future Hub-fed lists stay consistent without re-tuning the
/// UI.
@override
Future<List<Evaluation>> list() async {
final sorted = [...Fixtures.evaluations];
sorted.sort((a, b) => b.skmEurPerYear.compareTo(a.skmEurPerYear));
return sorted;
}
@override
Future<Evaluation?> byEli(String eli) async {
for (final e in Fixtures.evaluations) {
if (e.norm.eli == eli) return e;
}
return null;
}
@override
String get mode => 'demo';
@override
String get hubLabel => 'in-memory fixtures (kein Hub)';
}