Skip to content

Adding a streak feature#24

Merged
sfanahata merged 4 commits intomainfrom
goals-ux
Sep 26, 2025
Merged

Adding a streak feature#24
sfanahata merged 4 commits intomainfrom
goals-ux

Conversation

@sfanahata
Copy link
Copy Markdown
Owner

Lets users see a streak that they're on when they've done activities for 4 or more days in a week.

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
fitfest Ready Ready Preview Comment Sep 26, 2025 7:58pm

Comment on lines +52 to +54
const activityDate = new Date(activity.date);
const dateString = activityDate.toISOString().split('T')[0]; // YYYY-MM-DD format
uniqueDays.add(dateString);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Potential bug: The streak API converts activity dates to UTC using toISOString(), which is inconsistent with other APIs that use local time, potentially causing incorrect streak calculations.
  • Description: The new streak API at /api/streak/route.ts converts activity dates to a UTC date string using activityDate.toISOString().split('T')[0]. This is inconsistent with the established pattern in other endpoints, such as /api/activities/route.ts, which parse dates into local time. This discrepancy can lead to incorrect streak calculations. For example, an activity logged by a user in a timezone with a significant UTC offset late on a Sunday night could be converted to Monday in UTC, causing it to be excluded from the current week's streak calculation and misaligning the user's activity log.

  • Suggested fix: Adopt the established date parsing logic from other API routes. Instead of converting to UTC with toISOString(), ensure the date from the database is treated as local time, similar to the logic in /api/activities/route.ts and /api/meals/route.ts, to ensure consistent date handling across the application.
    severity: 0.75, confidence: 0.95

Did we get this right? 👍 / 👎 to inform future reviews.

@sfanahata sfanahata merged commit b909fd2 into main Sep 26, 2025
1 of 2 checks passed
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.

1 participant