Scope: Store and aggregate session and module duration data (covers categories 2 & 3).
Tasks:
- Create
SessionAggregate model:
date (DateField, indexed)
total_sessions (IntegerField)
total_duration_seconds (BigIntegerField)
avg_duration_seconds (IntegerField)
duration_buckets (JSONField) - histogram data
- Create
ModuleDurationAggregate model:
date (DateField, indexed)
exercise_type (IntegerField)
unit_id (IntegerField, nullable)
total_duration_seconds (BigIntegerField)
session_count (IntegerField)
avg_duration_seconds (IntegerField)
- Handle event types:
session_start, session_end, module_duration
- Session payload:
{ "session_id": string }
- Module payload:
{ "exercise_type": number, "unit_id": number | null, "duration_seconds": number }
- Calculate duration from matching start/end events
- Create duration histogram buckets: 0-1min, 1-5min, 5-15min, 15-30min, 30min+
Tracking Start (Session): App comes to foreground (AppState = 'active')
Tracking End (Session): App goes to background (AppState = 'background')
Tracking (Module): Single event sent when leaving exercise screen
References:
- AppState hook:
lunes-app/src/hooks/useAppState.ts
- Exercise types:
lunes-app/src/constants/data.ts
Scope: Store and aggregate session and module duration data (covers categories 2 & 3).
Tasks:
SessionAggregatemodel:date(DateField, indexed)total_sessions(IntegerField)total_duration_seconds(BigIntegerField)avg_duration_seconds(IntegerField)duration_buckets(JSONField) - histogram dataModuleDurationAggregatemodel:date(DateField, indexed)exercise_type(IntegerField)unit_id(IntegerField, nullable)total_duration_seconds(BigIntegerField)session_count(IntegerField)avg_duration_seconds(IntegerField)session_start,session_end,module_duration{ "session_id": string }{ "exercise_type": number, "unit_id": number | null, "duration_seconds": number }Tracking Start (Session): App comes to foreground (AppState = 'active')
Tracking End (Session): App goes to background (AppState = 'background')
Tracking (Module): Single event sent when leaving exercise screen
References:
lunes-app/src/hooks/useAppState.tslunes-app/src/constants/data.ts