- Change `getMediaDetail` JOIN to LEFT JOIN on `imm_lifetime_media` and fall back to aggregated session metrics when no lifetime row exists - Add filter `AND (lm.video_id IS NOT NULL OR s.session_id IS NOT NULL)` to keep results valid - Add regression test covering the session-visible / media-detail-missing mismatch
2.8 KiB
id, title, status, assignee, created_date, updated_date, labels, dependencies, priority
| id | title | status | assignee | created_date | updated_date | labels | dependencies | priority | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| TASK-346 | Fix stats session detail when recent media is missing | Done |
|
2026-05-12 06:41 | 2026-05-12 06:44 |
|
high |
Description
Stats overview can show a completed session, but clicking it opens a detail view that says "Media not found". The details view should resolve the session/media consistently for recently completed local playback so users can inspect session cards, words, timeline, and media stats after a video finishes.
Acceptance Criteria
- #1 A completed session listed on the stats overview opens a usable details view instead of "Media not found" when its media is still present in stats data.
- #2 Regression coverage reproduces the overview-to-detail lookup mismatch and verifies the corrected behavior.
- #3 Relevant stats/detail documentation is updated if behavior or APIs change.
Implementation Plan
- Add a focused regression test in
src/core/services/immersion-tracker/__tests__/query.test.tscovering a video/session visible from session summaries beforeimm_lifetime_mediaexists. - Update
getMediaDetailinsrc/core/services/immersion-tracker/query-library.tsso detail rows can resolve fromimm_videosplus session metrics when lifetime summary is absent. - Run the focused query test lane and update task notes/acceptance criteria.
Implementation Notes
Implemented root-cause fix in getMediaDetail: media detail now resolves from imm_videos plus session metrics when imm_lifetime_media is not populated yet, while still preferring lifetime summary totals when available. Added regression test for session-visible/media-detail-missing mismatch. No docs update required because the API shape is unchanged; added changelog fragment changes/346-stats-session-detail.md. Verification: bun test src/core/services/immersion-tracker/__tests__/query.test.ts, bun run typecheck, bun run format:check:src, bun run test:fast, bun run changelog:lint.
Final Summary
Summary:
- Fixed stats media detail lookup so sessions visible in overview can open detail even before lifetime media summaries exist.
- Preserved lifetime-summary totals when available and added a regression test for the missing-lifetime case.
- Added
changes/346-stats-session-detail.mdfor the user-visible fix.
Tests:
bun test src/core/services/immersion-tracker/__tests__/query.test.tsbun run typecheckbun run format:check:srcbun run test:fastbun run changelog:lint