Fix: Weekly view missing days and Today's focus not appearing in graph#203
Open
sayeedjoy wants to merge 1 commit intonsh07:mainfrom
Open
Fix: Weekly view missing days and Today's focus not appearing in graph#203sayeedjoy wants to merge 1 commit intonsh07:mainfrom
sayeedjoy wants to merge 1 commit intonsh07:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the weekly stats graph was missing days that had no recorded focus time, causing gaps in the display (Thursday and Friday were missing) and preventing today's focus time from appearing.
Changes:
- Removed the
.filter { it.isNotEmpty() }fromlastWeekStatsFlowto allow the graph to update even with sparse data - Modified
lastWeekMainChartDatato generate an explicit 7-day date range and map database results to it, filling missing days with 0 - Modified
lastWeekFocusHistoryValuesto use the same 7-day range approach for consistency
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/viewModel/StatsViewModel.kt
Show resolved
Hide resolved
Owner
|
The core issue is not that the empty days in the database are not being shown in the app, it is the fact that somehow a gap in the recorded days slipped in. The database of this app is supposed to have a continuous sequence of days without gaps, and var lastDate = statRepository.getLastDate()
val today = LocalDate.now()
// Fills dates between today and lastDate with 0s to ensure continuous history
if (lastDate != null) {
while (ChronoUnit.DAYS.between(lastDate, today) > 0) {
lastDate = lastDate?.plusDays(1)
statRepository.insertStat(Stat(lastDate!!, 0, 0, 0, 0, 0))
}
} else {
statRepository.insertStat(Stat(today, 0, 0, 0, 0, 0))
}Why this does not work in the user's case is the actual problem, and not just the display of data. |
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.
Issue
In the Weekly Stats view, the graph was not displaying all days correctly, as reported in #201.
Thursday and Friday were missing, and after Wednesday the graph jumped directly to Saturday/Sunday.
Additionally, today’s focus time was visible elsewhere in the UI but did not appear in the weekly graph.
Cause
The weekly graph logic relied directly on the result of
getLastNDaysStats(7), which returns only the days that have recorded data.If focus time was not recorded on certain days, those days were excluded from the result, causing gaps in the graph.
Additionally,
lastWeekStatsFlowused.filter { it.isNotEmpty() }, which prevented the graph from rendering when data was sparse or partially missing.Fix
The stats calculation was updated to ensure a consistent 7-day display:
0focus time..filter { it.isNotEmpty() }condition so the graph updates even when some days have no data.Result
0.