forked from firka/firka
- 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
30 lines
797 B
Dart
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);
|
|
});
|
|
}
|