Conversation
…before under safe-area)
…rd from blue to green
… and WorkoutSessionService
…Calendar.vue for improved event display
There was a problem hiding this comment.
Pull request overview
Introduces a “streak freeze” mechanic into the streak system (backend persistence + API + frontend UI), along with related calendar/home visual updates and some service-layer refactors to support transactional statistics updates.
Changes:
- Added streak-freeze persistence (new user columns + migration) and exposed freeze status in streak APIs.
- Implemented
POST /users/streak/freezeand integrated frontend UI flows (Calendar freeze card/dialog + home icon/status). - Refactored statistics record upsert to accept an optional
EntityManagerand wired it through workout-session transaction paths.
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/services/user.service.ts | Adds client call for the streak-freeze endpoint. |
| frontend/src/pages/WorkoutDetails.vue | Adjusts layout by removing sticky start button styling. |
| frontend/src/pages/Session.vue | Minor spacing adjustment in session header container. |
| frontend/src/pages/index.vue | Updates weekly-goal card to reflect freeze state visually. |
| frontend/src/pages/Calendar.vue | Adds freeze UI + calendar badge redesign + monthly stats card changes. |
| frontend/src/locales/sv.ts | Adds Swedish strings for freeze UI/labels. |
| frontend/src/locales/en.ts | Adds English strings for freeze UI/labels. |
| frontend/src/interfaces/User.interface.ts | Extends StreakInfo with freeze-related fields. |
| frontend/src/components/Session/WorkoutExerciseCard.vue | Adds quick “add set” icon and refines details toggle behavior/styling. |
| frontend/package.json | Bumps frontend version to 1.1.0. |
| frontend/package-lock.json | Updates lockfile version metadata and dependency flags. |
| backend/src/v1/workoutSession/workoutSession.service.ts | Passes transaction EntityManager into statistics record upsert calls. |
| backend/src/v1/user/user.service.ts | Implements freeze logic, awarding/consumption, and enriches streak info response. |
| backend/src/v1/user/user.entity.ts | Adds new user columns for freeze tracking and goal-week counters. |
| backend/src/v1/user/user.controller.ts | Adds POST /users/streak/freeze endpoint and export formatting changes. |
| backend/src/v1/statistics/statistics.service.ts | Allows record upsert to use a provided EntityManager for transactional consistency. |
| backend/src/v1/migrations/1775000000000-AddStreakFreezesToUser.ts | Creates the new streak-freeze and goal-week tracking columns. |
| backend/package.json | Bumps backend version to 1.1.0. |
| backend/package-lock.json | Updates backend lockfile version metadata. |
Files not reviewed (2)
- backend/package-lock.json: Language not supported
- frontend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else { | ||
| // Goal met for exactly last week — award a freeze if earned | ||
| user.completedGoalWeeksCount = (user.completedGoalWeeksCount || 0) + 1; | ||
| if ( | ||
| user.completedGoalWeeksCount % 2 === 0 && | ||
| (user.streakFreezes || 0) < 2 | ||
| ) { | ||
| user.streakFreezes = (user.streakFreezes || 0) + 1; | ||
| } | ||
| } |
There was a problem hiding this comment.
Fixed in commit 5763d77. Added user.lastStreakCheckDate = currentWeekMonday inside checkAndResetWeeklyProgress after the week rollover logic runs. This ensures that subsequent calls (e.g. repeated getStreakInfo calls within the same new week) see lastStreakCheckDate already pointing to the current week's Monday and skip the rollover, preventing completedGoalWeeksCount from being incremented multiple times and duplicate freeze awards.
| const now = new Date(); | ||
| const currentWeekKey = this.getISOWeekKey(now); | ||
| const targetDate = new Date(date + 'T12:00:00'); | ||
| const targetWeekKey = this.getISOWeekKey(targetDate); | ||
|
|
||
| if (targetWeekKey !== currentWeekKey) { | ||
| throw new BadRequestException('Can only freeze the current week'); | ||
| } |
There was a problem hiding this comment.
Fixed in commit 422854f. Added a Number.isNaN(targetDate.getTime()) guard that returns a clear 400 "Invalid date format" error for unparseable date strings (defence-in-depth for direct service calls that bypass the HTTP pipeline). The redundant !date null check was omitted since the DTO's @IsDateString() already enforces presence at the controller layer.
| @Post('streak/freeze') | ||
| @ApiOperation({ summary: 'Use a streak freeze to protect the current week' }) | ||
| @ApiOkResponse({ | ||
| description: 'Updated streak info after consuming the freeze', | ||
| }) | ||
| useStreakFreeze(@Req() req: RequestWithUser, @Body() body: { date: string }) { | ||
| if (!req.user?.id) { | ||
| throw new UnauthorizedException('User not authenticated'); | ||
| } | ||
| return this.userService.useStreakFreeze(+req.user.id, body.date); | ||
| } |
There was a problem hiding this comment.
Fixed in commit 422854f. Created UseStreakFreezeDto with @IsDateString() and @ApiProperty in backend/src/v1/user/dto/UseStreakFreeze.dto.ts, and updated the controller to accept @Body() body: UseStreakFreezeDto so the global ValidationPipe now validates and rejects invalid/missing date values, and Swagger reflects the schema.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…vent repeated rollover Agent-Logs-Url: https://github.com/FalkenDev/Grindify/sessions/e0e89066-dcb4-45d7-9fd2-9ff9dccc179a Co-authored-by: FalkenDev <88202349+FalkenDev@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/FalkenDev/Grindify/sessions/95ccf618-5492-45cf-a71e-3214d323c810 Co-authored-by: FalkenDev <88202349+FalkenDev@users.noreply.github.com>
…n-depth Agent-Logs-Url: https://github.com/FalkenDev/Grindify/sessions/95ccf618-5492-45cf-a71e-3214d323c810 Co-authored-by: FalkenDev <88202349+FalkenDev@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This pull request introduces the "streak freeze" feature to the user streak system, allowing users to protect their workout streaks from being reset under certain conditions. It also includes related schema changes, API updates, and improvements to user statistics tracking. Additionally, there are minor updates to package versions and some formatting changes.
Streak Freeze Feature and Streak System Enhancements:
usertable:streakFreezes(number of available freezes),streakFreezeUsedWeek(tracks which week a freeze was used), andcompletedGoalWeeksCount(tracks completed goal weeks). Includes migration and entity updates. [1] [2]getISOWeekKeyfor week identification, and exposed streak freeze information in the streak info API response. [1] [2] [3]API Changes:
POST /user/streak/freezeto allow users to consume a streak freeze for the current week.Statistics and Service Layer Improvements:
EntityManager, improving transaction support and code flexibility. [1] [2] [3] [4] [5] [6] [7] [8] [9]Package and Dependency Updates:
1.0.0to1.1.0and made minor adjustments to the frontend package-lock file regarding dev and optional dependencies. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]