Codex/improve statsscreen UI and metrics#309
Conversation
- Use squircle shape for stats overview card. - Adjust padding, spacing, and layout on the stats screen for a cleaner appearance. - Refine the styling of metric filter chips.
- Remove redundant summary section from the main stats screen, as it's already in the overview card. - Adjust padding in the `StatsOverviewCard` to remove extra top padding. - Change the default category dimension to "Song". - Improve the visual design of the `CategoryVerticalBarChart` by using circular shapes for bars and adding a horizontal divider. - Remove the highlight row from under the category chart.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fun finalizeCurrentSession() { | ||
| val session = currentSession ?: return | ||
| val nowRealtime = SystemClock.elapsedRealtime() | ||
| if (session.isPlaying) { | ||
| session.accumulatedListeningMs += (nowRealtime - session.lastRealtimeMs).coerceAtLeast(0L) | ||
| } | ||
| val totalCap = if (session.totalDurationMs > 0) session.totalDurationMs else Long.MAX_VALUE | ||
| val listened = session.accumulatedListeningMs.coerceAtMost(totalCap).coerceAtLeast(0L) | ||
| if (listened >= MIN_SESSION_LISTEN_MS) { | ||
| val timestamp = System.currentTimeMillis() | ||
| val songId = session.songId | ||
| viewModelScope.launch(Dispatchers.IO) { | ||
| dailyMixManager.recordPlay( | ||
| songId = songId, | ||
| songDurationMs = listened, | ||
| timestamp = timestamp | ||
| ) | ||
| playbackStatsRepository.recordPlayback( | ||
| songId = songId, | ||
| durationMs = listened, | ||
| timestamp = timestamp | ||
| ) |
There was a problem hiding this comment.
Record stats using last playback timestamp, not finalization time
When a session is finalized the code creates the playback event with timestamp = System.currentTimeMillis(). That reflects when the session was closed, not when the user was actually listening. If the user pauses a track and only changes songs or closes the app hours later, the accumulated listening time is recorded at the later time window, which will skew daily/weekly timelines, streaks and peak-hour calculations. Using the session’s tracked start/last update timestamps (e.g. session.lastUpdateEpochMs) would better represent the true listening period.
Useful? React with 👍 / 👎.
No description provided.