SessionHistoryService class
Hive-backed service for individual session records, streaks, and stats.
All sessions stored as JSON maps in a single Hive box keyed by session ID. Streak info cached in separate keys for fast reads.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
currentStreak(
) → Future< int> - Current consecutive-day streak.
-
getHistory(
{int? limit, String? stateId}) → Future< List< SessionRecord> > - Get all sessions, newest first. Optional filters.
-
longestStreak(
) → Future< int> - Longest ever streak.
-
recalculateStreaks(
) → Future< void> - Recalculate streaks from raw session data (recovery/debug).
-
recentSessions(
{int days = 7}) → Future< List< SessionRecord> > - Sessions in the last N days, newest first.
-
recordSession(
{required String stateId, required DateTime startedAt, required int elapsedSeconds, required bool completedFull, String? emotion}) → Future< SessionRecord> - Record a completed session. Updates streak counters.
-
sessionsByDay(
{int days = 30}) → Future< Map< String, int> > - Session count grouped by date (YYYY-MM-DD) for the last N days.
-
sessionsByState(
) → Future< Map< String, int> > - Session count grouped by stateId.
-
totalSessions(
) → Future< int> - Total number of sessions.
-
totalTime(
) → Future< Duration> - Total time spent across all sessions.
-
updateEmotion(
String stateId, String emoji) → Future< void> - Update emotion for the most recent session of a given state.