Skip to content

bug: Local date boundary mismatch in historical graph filters excludes boundary day data #298

Description

@yashvi-3106

Description:

In the profile view, filtering historical user stats (weekly or monthly views) excludes data points on the boundary date due to timezone/time-of-day offsets. The filter threshold filterDate is created using the client's local system time (e.g., new Date() minus 7/30 days). In contrast, user history records have dates stored in YYYY-MM-DD strings, which JavaScript parses as UTC midnight (00:00:00Z).
Because the local date has hours/minutes set, the condition new Date(item.date) >= filterDate evaluates to false for entries on the boundary day (since 00:00:00 is less than the current time of day, e.g., 10:30:00), causing boundary records to disappear depending on the hour of the day.

To Reproduce

  1. Register/log a user activity snapshot daily.
  2. View the weekly/monthly performance graphs on the profile page.
  3. Depending on the time of day, notice that the earliest boundary day data point is skipped from the graph.

Code Reference

In frontend/js/user/historical-graphs.js:

Suggested Fix

Normalize filterDate to start at local midnight:

if (filterDate) {
  filterDate.setHours(0, 0, 0, 0);
}

---

Metadata

Metadata

Assignees

Labels

FrontendTask mainly involving frontendlevel:beginnerIndicates the difficultytype:bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions