Skip to content

Fix: Weekly view missing days and Today's focus not appearing in graph#203

Open
sayeedjoy wants to merge 1 commit intonsh07:mainfrom
sayeedjoy:main
Open

Fix: Weekly view missing days and Today's focus not appearing in graph#203
sayeedjoy wants to merge 1 commit intonsh07:mainfrom
sayeedjoy:main

Conversation

@sayeedjoy
Copy link

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, lastWeekStatsFlow used .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:

  • Generated an explicit 7-day date range (today − 6 days to today).
  • Mapped database results to this fixed date range, filling missing days with 0 focus time.
  • Removed the .filter { it.isNotEmpty() } condition so the graph updates even when some days have no data.

Result

  • The weekly graph now always shows all 7 days without skipping any.
  • Days with no focus time correctly display 0.
  • Today’s focus time reliably appears in the weekly graph.

Copilot AI review requested due to automatic review settings January 20, 2026 18:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() } from lastWeekStatsFlow to allow the graph to update even with sparse data
  • Modified lastWeekMainChartData to generate an explicit 7-day date range and map database results to it, filling missing days with 0
  • Modified lastWeekFocusHistoryValues to use the same 7-day range approach for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nsh07
Copy link
Owner

nsh07 commented Feb 1, 2026

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 TimerViewModel's init takes care of this:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants