Skip to content

[DT-CMS-2-1] Session & Module Duration Tracking #663

@sascha11110

Description

@sascha11110

Scope: Store and aggregate session and module duration data (covers categories 2 & 3).

Tasks:

  1. Create SessionAggregate model:
    • date (DateField, indexed)
    • total_sessions (IntegerField)
    • total_duration_seconds (BigIntegerField)
    • avg_duration_seconds (IntegerField)
    • duration_buckets (JSONField) - histogram data
  2. Create ModuleDurationAggregate model:
    • date (DateField, indexed)
    • exercise_type (IntegerField)
    • unit_id (IntegerField, nullable)
    • total_duration_seconds (BigIntegerField)
    • session_count (IntegerField)
    • avg_duration_seconds (IntegerField)
  3. 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 }
  4. Calculate duration from matching start/end events
  5. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions