1
0
forked from firka/firka
Files
firka/firka_wear/lib/data/models/homework_cache_model.dart
Armand 32936c2aa5 firka: extract firka_common package with shared widgets (Isar kept separate)
- Create firka_common package with core helpers (debug, json, icon), theme,
  and shared widgets (FirkaCard, FirkaShadow, GradeWidget, GradeSmallCard,
  ClassIconWidget, FirkaIconWidget, DelayedSpinnerWidget, CounterDigitWidget)
- Keep Isar models (GenericCacheModel, TimetableCacheModel, HomeworkCacheModel,
  DatedCacheEntry, util) in firka and firka_wear - not moved to firka_common
- Update firka and firka_wear to depend on firka_common for shared UI only
- Add configurable roundGrade thresholds for firka settings
- Add package param to FirkaIconWidget for app asset paths
2026-03-03 15:33:11 +01:00

30 lines
797 B
Dart

import 'package:isar_community/isar.dart';
import 'package:firka_wear/core/debug_helper.dart';
import 'package:firka_wear/data/util.dart';
part 'homework_cache_model.g.dart';
@collection
class HomeworkCacheModel extends DatedCacheEntry {
HomeworkCacheModel();
}
Future<void> resetOldHomeworkCache(Isar isar) async {
var now = timeNow();
var weeks = await isar.homeworkCacheModels.where().findAll();
var weeksToRemove = List<Id>.empty(growable: true);
for (var week in weeks) {
var date = getDate(week.cacheKey!);
if (date.millisecondsSinceEpoch <
now.subtract(const Duration(days: 30)).millisecondsSinceEpoch) {
weeksToRemove.add(week.cacheKey!);
}
}
await isar.writeTxn(() async {
await isar.homeworkCacheModels.deleteAll(weeksToRemove);
});
}