feat: set up Flutter project with drift database, Riverpod providers, and LLM service layer
- Configure dependencies: drift 2.32.x, flutter_riverpod 3.3.1, fl_chart 1.2.x, flutter_local_notifications 21.x, local_auth 3.x, and supporting packages - Drop riverpod_generator (incompatible analyzer version with drift_dev 2.32.x); convert all providers to manual Riverpod 3.x API using Notifier<T> and typed families - Define drift schema: MoodEntries, Activities, EntryActivities, Tags, EntryTags, LlmInsights, UserSettings with four DAOs (mood, activity, insight, settings) - Add LLM service abstraction (LlmService) and MediaPipe implementation - Fix SettingsDao.delete → deleteByKey to avoid shadowing drift's inherited delete method
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import '../app_database.dart';
|
||||
import '../tables.dart';
|
||||
|
||||
part 'insight_dao.g.dart';
|
||||
|
||||
@DriftAccessor(tables: [LlmInsights])
|
||||
class InsightDao extends DatabaseAccessor<AppDatabase> with _$InsightDaoMixin {
|
||||
InsightDao(super.db);
|
||||
|
||||
Future<LlmInsight?> getCached(String promptHash) => (select(llmInsights)
|
||||
..where((t) => t.promptHash.equals(promptHash))
|
||||
..limit(1))
|
||||
.getSingleOrNull();
|
||||
|
||||
Future<void> upsertInsight(LlmInsightsCompanion insight) =>
|
||||
into(llmInsights).insertOnConflictUpdate(insight);
|
||||
|
||||
// Purge cached insights older than 7 days
|
||||
Future<void> purgeStale() {
|
||||
final cutoff = DateTime.now().subtract(const Duration(days: 7));
|
||||
return (delete(llmInsights)
|
||||
..where((t) => t.generatedAt.isSmallerThanValue(cutoff)))
|
||||
.go();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user