feat: implement background LLM pattern analysis on Insights screen
Adds a prompt builder that serialises 7-day mood/activity data, wires InsightNotifier to call the on-device LLM directly (no user interaction), caches results by prompt hash, and renders the analysis as a passive card. Includes loading, empty (<2 entries), and error states with a force-refresh button.
This commit is contained in:
@@ -84,6 +84,22 @@ class MoodDao extends DatabaseAccessor<AppDatabase> with _$MoodDaoMixin {
|
||||
.getSingleOrNull()) != null;
|
||||
}
|
||||
|
||||
// Entries with their linked activities — used by LLM prompt builder
|
||||
Future<List<MoodEntryWithActivities>> getEntriesWithActivitiesInRange(
|
||||
DateTime start, DateTime end) async {
|
||||
final entries = await getEntriesInRange(start, end);
|
||||
return Future.wait(entries.map((e) async {
|
||||
final links = await (select(entryActivities)
|
||||
..where((t) => t.entryId.equals(e.id)))
|
||||
.get();
|
||||
final actIds = links.map((l) => l.activityId).toList();
|
||||
final acts = actIds.isEmpty
|
||||
? <Activity>[]
|
||||
: await (select(activities)..where((t) => t.id.isIn(actIds))).get();
|
||||
return MoodEntryWithActivities(entry: e, activities: acts, tags: []);
|
||||
}));
|
||||
}
|
||||
|
||||
// Average mood per day — used by calendar heatmap
|
||||
Future<Map<DateTime, double>> getDailyAverages(
|
||||
DateTime start, DateTime end) async {
|
||||
|
||||
Reference in New Issue
Block a user