feat(harmonia-db): play history, scrobble tracking, and listening analytics (P2-14)#45
Merged
forkwright merged 1 commit intomainfrom Mar 12, 2026
Merged
feat(harmonia-db): play history, scrobble tracking, and listening analytics (P2-14)#45forkwright merged 1 commit intomainfrom
forkwright merged 1 commit intomainfrom
Conversation
…lytics (P2-14) - Migration 002_play_history.sql: play_sessions, play_stats_daily, play_stats_item, play_streaks tables with appropriate indexes - harmonia-common: SessionId newtype (UUIDv7, "sess-" prefix) - harmonia-common/aggelia: NowPlayingStarted and PlaybackSessionEnded event variants with serde roundtrip tests - harmonia-db/repo/play_history: session lifecycle, scrobble queue, incremental stats aggregation, analytics queries (top_items, listening_time, daily_activity, on_this_day, streak tracking), and discovery helpers (never_played, not_played_since) - 20 tests covering all specified scenarios
This was referenced Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
002_play_history.sql: four new tables —play_sessions(one row per contiguous playback),play_stats_daily(pre-computed daily aggregates),play_stats_item(per-item lifetime stats),play_streaks(consecutive-day tracking) — with indexes for common query patternsSessionIdnewtype added toharmonia-common/ids.rs(UUIDv7,"sess-"prefix)NowPlayingStarted/PlaybackSessionEndedvariants added toHarmoniaEventwith serde roundtrip testscrates/harmonia-db/src/repo/play_history.rs: full repository module — session lifecycle, scrobble queue, incremental stats upserts, analytics queries (top_items,listening_time,daily_activity,on_this_day), streak tracking, and discovery helpers (never_played,not_played_since)Test plan
cargo check -p harmonia-db -p harmonia-common— cleancargo test -p harmonia-db -p harmonia-common— 56 tests pass (20 new in play_history)cargo clippy -p harmonia-db -p harmonia-common -- -D warnings— cleancargo fmt --all— no diffCovers all scenarios from the spec: session lifecycle, scrobble eligibility and submission, stats aggregation (play count, skip count, first/last played, daily upserts), analytics queries, streak create/extend/gap logic, event serde.