fix: Workout API and production tweaks#70
Conversation
NickSavino
commented
Mar 19, 2026
- updated workout session history endpoint
- added reset_workflow script along with github action
- added ingestion functionality for webhook
Review Summary by QodoEnhance workout API with history aggregation and user deletion webhook support
WalkthroughsDescription• Enhanced workout session history endpoint with aggregated set/rep counts • Added user deletion webhook handler for Clerk integration • Removed calibration angles from session history query optimization • Added database reset automation script and GitHub workflow Diagramflowchart LR
A["Clerk Webhook Events"] -->|user.created| B["HandleCreateUserFromClerk"]
A -->|user.deleted| C["HandleDeleteUserFromClerk"]
B --> D["Create User in DB"]
C --> E["Delete User by ClerkID"]
F["GetUserWorkoutSessionHistory"] -->|Query with JOINs| G["Aggregate Sets/Reps"]
G --> H["WorkoutSessionHistoryItemDTO"]
I["Database Reset Script"] -->|AWS SSM| J["Run Migrations"]
K["GitHub Workflow"] -->|Manual Trigger| I
File Changes1. internal/core/service/user.service.go
|
Code Review by Qodo
1. Reset image may be missing
|
| - name: Run database reset | ||
| env: | ||
| AWS_REGION: ${{ secrets.AWS_REGION }} | ||
| ECR_REPO: ${{ secrets.ECR_REPO }} | ||
| EC2_INSTANCE_ID: ${{ secrets.EC2_INSTANCE_ID }} | ||
| GITHUB_SHA: ${{ github.sha }} | ||
| run: | | ||
| bash ./scripts/ci/reset_database.sh No newline at end of file |
There was a problem hiding this comment.
1. Reset image may be missing 🐞 Bug ⛯ Reliability
reset-database pulls a migrator image tagged with the current github.sha but the workflow never builds/pushes that tag, so docker pull can fail and the reset becomes non-functional. This is especially likely when manually dispatching on a commit that wasn’t built/pushed (or after ECR cleanup).
Agent Prompt
### Issue description
The `Reset Database` workflow pulls a migrator image tagged with `${github.sha}-migrate`, but it never builds/pushes that image in the workflow. This can cause `docker pull` to fail and the reset workflow to be unusable.
### Issue Context
`reset_database.sh` constructs `MIGRATOR_IMAGE_URI="...:${GITHUB_SHA}-migrate"` and pulls it on the EC2 host via SSM. The deploy workflow builds/pushes images first; the reset workflow does not.
### Fix Focus Areas
- .github/workflows/reset-database.yml[20-37]
- scripts/ci/reset_database.sh[9-23]
### Suggested fix
Add a build/push step (or a reusable workflow call) before running `reset_database.sh`, or change the workflow to accept an explicit image tag input (e.g., last successful deploy SHA) and use that for `MIGRATOR_IMAGE_URI`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
* Small changes to dev tooling (docker/make/compose * Server: minor variable rename * Auth middleware + clerk webhook handler * Added WithTransaction to store * Removed debug logging message exposing userid * Removed docker-compose changes not relevant to PR * Renamed users.go to users.handler.go in handlers * Added documentation explaining dev bypass * Feat/calibration-endpoints (#57) * added user calibration endpoints and schema" - Added user_calibration migration - Added sqlc queries for calibration CRUD operations - added /api/users/me/calibration endpoints: GET, POST, DELETE - me endpoint now fetches user from clerk id using middleware, enhancing security - removed GET methods for user (GET /{id}, GET /) * Fixed line endings * Fixed time formatting in handler * Added NOT NULL constrain to updated_at, created_at in db table switch go dev container port to correct mapping (8080) fixed variable typo in middleware_auth.go --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Fixed syntax error on migration (#58) Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Feat/workouts api (#59) * Implemented workout and calibration schema with included sqlc queries. Updated makefile and seeding files * Regenerated SQLC to match new queries and models (workout type + workout session) * Added workout session service * Added Workout Handler Endpoint * Addressed PR comments - fixed syntax error in makefile - Fixed migration schema - fixed seeding script - added /service/helps/helpers.util file - renamed Dtos to match go standards, (Id -> ID) * Updated API endpoints * updated dtos to match casing convention. updated workout_session logic * Added functionality for workout sets and reps. (services, handlers, migrations, queries) * Addressed PR comments * Addressed PR comments --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: added clerk webhook secret (#62) * Fix/add clerkwebhook secret (#64) * fix: added clerk webhook secret * updated CRLF line endings to LF * Fix/add clerkwebhook secret (#66) * fix: added clerk webhook secret * updated CRLF line endings to LF * fix * prod fix * Seed Script: Wipe Data (#69) * Prod fix (#67) * Small changes to dev tooling (docker/make/compose * Server: minor variable rename * Auth middleware + clerk webhook handler * Added WithTransaction to store * Removed debug logging message exposing userid * Removed docker-compose changes not relevant to PR * Renamed users.go to users.handler.go in handlers * Added documentation explaining dev bypass * Feat/calibration-endpoints (#57) * added user calibration endpoints and schema" - Added user_calibration migration - Added sqlc queries for calibration CRUD operations - added /api/users/me/calibration endpoints: GET, POST, DELETE - me endpoint now fetches user from clerk id using middleware, enhancing security - removed GET methods for user (GET /{id}, GET /) * Fixed line endings * Fixed time formatting in handler * Added NOT NULL constrain to updated_at, created_at in db table switch go dev container port to correct mapping (8080) fixed variable typo in middleware_auth.go --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Fixed syntax error on migration (#58) Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Feat/workouts api (#59) * Implemented workout and calibration schema with included sqlc queries. Updated makefile and seeding files * Regenerated SQLC to match new queries and models (workout type + workout session) * Added workout session service * Added Workout Handler Endpoint * Addressed PR comments - fixed syntax error in makefile - Fixed migration schema - fixed seeding script - added /service/helps/helpers.util file - renamed Dtos to match go standards, (Id -> ID) * Updated API endpoints * updated dtos to match casing convention. updated workout_session logic * Added functionality for workout sets and reps. (services, handlers, migrations, queries) * Addressed PR comments * Addressed PR comments --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: added clerk webhook secret (#62) * Fix/add clerkwebhook secret (#64) * fix: added clerk webhook secret * updated CRLF line endings to LF * Fix/add clerkwebhook secret (#66) * fix: added clerk webhook secret * updated CRLF line endings to LF * fix --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: wipe data on seed --------- Co-authored-by: Nicola Savino <77707655+NickSavino@users.noreply.github.com> Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: (#70) - updated workout session history endpoint - added reset_workflow script along with github action - added ingestion functionality for webhook --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> Co-authored-by: Aarsh Shah <86862845+AarshShah9@users.noreply.github.com>
* Small changes to dev tooling (docker/make/compose * Server: minor variable rename * Auth middleware + clerk webhook handler * Added WithTransaction to store * Removed debug logging message exposing userid * Removed docker-compose changes not relevant to PR * Renamed users.go to users.handler.go in handlers * Added documentation explaining dev bypass * Feat/calibration-endpoints (#57) * added user calibration endpoints and schema" - Added user_calibration migration - Added sqlc queries for calibration CRUD operations - added /api/users/me/calibration endpoints: GET, POST, DELETE - me endpoint now fetches user from clerk id using middleware, enhancing security - removed GET methods for user (GET /{id}, GET /) * Fixed line endings * Fixed time formatting in handler * Added NOT NULL constrain to updated_at, created_at in db table switch go dev container port to correct mapping (8080) fixed variable typo in middleware_auth.go --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Fixed syntax error on migration (#58) Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Feat/workouts api (#59) * Implemented workout and calibration schema with included sqlc queries. Updated makefile and seeding files * Regenerated SQLC to match new queries and models (workout type + workout session) * Added workout session service * Added Workout Handler Endpoint * Addressed PR comments - fixed syntax error in makefile - Fixed migration schema - fixed seeding script - added /service/helps/helpers.util file - renamed Dtos to match go standards, (Id -> ID) * Updated API endpoints * updated dtos to match casing convention. updated workout_session logic * Added functionality for workout sets and reps. (services, handlers, migrations, queries) * Addressed PR comments * Addressed PR comments --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: added clerk webhook secret (#62) * Fix/add clerkwebhook secret (#64) * fix: added clerk webhook secret * updated CRLF line endings to LF * Fix/add clerkwebhook secret (#66) * fix: added clerk webhook secret * updated CRLF line endings to LF * fix * prod fix * Seed Script: Wipe Data (#69) * Prod fix (#67) * Small changes to dev tooling (docker/make/compose * Server: minor variable rename * Auth middleware + clerk webhook handler * Added WithTransaction to store * Removed debug logging message exposing userid * Removed docker-compose changes not relevant to PR * Renamed users.go to users.handler.go in handlers * Added documentation explaining dev bypass * Feat/calibration-endpoints (#57) * added user calibration endpoints and schema" - Added user_calibration migration - Added sqlc queries for calibration CRUD operations - added /api/users/me/calibration endpoints: GET, POST, DELETE - me endpoint now fetches user from clerk id using middleware, enhancing security - removed GET methods for user (GET /{id}, GET /) * Fixed line endings * Fixed time formatting in handler * Added NOT NULL constrain to updated_at, created_at in db table switch go dev container port to correct mapping (8080) fixed variable typo in middleware_auth.go --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Fixed syntax error on migration (#58) Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Feat/workouts api (#59) * Implemented workout and calibration schema with included sqlc queries. Updated makefile and seeding files * Regenerated SQLC to match new queries and models (workout type + workout session) * Added workout session service * Added Workout Handler Endpoint * Addressed PR comments - fixed syntax error in makefile - Fixed migration schema - fixed seeding script - added /service/helps/helpers.util file - renamed Dtos to match go standards, (Id -> ID) * Updated API endpoints * updated dtos to match casing convention. updated workout_session logic * Added functionality for workout sets and reps. (services, handlers, migrations, queries) * Addressed PR comments * Addressed PR comments --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: added clerk webhook secret (#62) * Fix/add clerkwebhook secret (#64) * fix: added clerk webhook secret * updated CRLF line endings to LF * Fix/add clerkwebhook secret (#66) * fix: added clerk webhook secret * updated CRLF line endings to LF * fix --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: wipe data on seed --------- Co-authored-by: Nicola Savino <77707655+NickSavino@users.noreply.github.com> Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: (#70) - updated workout session history endpoint - added reset_workflow script along with github action - added ingestion functionality for webhook --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> Co-authored-by: Aarsh Shah <86862845+AarshShah9@users.noreply.github.com>
* Small changes to dev tooling (docker/make/compose * Server: minor variable rename * Auth middleware + clerk webhook handler * Added WithTransaction to store * Removed debug logging message exposing userid * Removed docker-compose changes not relevant to PR * Renamed users.go to users.handler.go in handlers * Added documentation explaining dev bypass * Feat/calibration-endpoints (#57) * added user calibration endpoints and schema" - Added user_calibration migration - Added sqlc queries for calibration CRUD operations - added /api/users/me/calibration endpoints: GET, POST, DELETE - me endpoint now fetches user from clerk id using middleware, enhancing security - removed GET methods for user (GET /{id}, GET /) * Fixed line endings * Fixed time formatting in handler * Added NOT NULL constrain to updated_at, created_at in db table switch go dev container port to correct mapping (8080) fixed variable typo in middleware_auth.go --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Fixed syntax error on migration (#58) Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Feat/workouts api (#59) * Implemented workout and calibration schema with included sqlc queries. Updated makefile and seeding files * Regenerated SQLC to match new queries and models (workout type + workout session) * Added workout session service * Added Workout Handler Endpoint * Addressed PR comments - fixed syntax error in makefile - Fixed migration schema - fixed seeding script - added /service/helps/helpers.util file - renamed Dtos to match go standards, (Id -> ID) * Updated API endpoints * updated dtos to match casing convention. updated workout_session logic * Added functionality for workout sets and reps. (services, handlers, migrations, queries) * Addressed PR comments * Addressed PR comments --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: added clerk webhook secret (#62) * Fix/add clerkwebhook secret (#64) * fix: added clerk webhook secret * updated CRLF line endings to LF * Fix/add clerkwebhook secret (#66) * fix: added clerk webhook secret * updated CRLF line endings to LF * fix * prod fix * Seed Script: Wipe Data (#69) * Prod fix (#67) * Small changes to dev tooling (docker/make/compose * Server: minor variable rename * Auth middleware + clerk webhook handler * Added WithTransaction to store * Removed debug logging message exposing userid * Removed docker-compose changes not relevant to PR * Renamed users.go to users.handler.go in handlers * Added documentation explaining dev bypass * Feat/calibration-endpoints (#57) * added user calibration endpoints and schema" - Added user_calibration migration - Added sqlc queries for calibration CRUD operations - added /api/users/me/calibration endpoints: GET, POST, DELETE - me endpoint now fetches user from clerk id using middleware, enhancing security - removed GET methods for user (GET /{id}, GET /) * Fixed line endings * Fixed time formatting in handler * Added NOT NULL constrain to updated_at, created_at in db table switch go dev container port to correct mapping (8080) fixed variable typo in middleware_auth.go --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Fixed syntax error on migration (#58) Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Feat/workouts api (#59) * Implemented workout and calibration schema with included sqlc queries. Updated makefile and seeding files * Regenerated SQLC to match new queries and models (workout type + workout session) * Added workout session service * Added Workout Handler Endpoint * Addressed PR comments - fixed syntax error in makefile - Fixed migration schema - fixed seeding script - added /service/helps/helpers.util file - renamed Dtos to match go standards, (Id -> ID) * Updated API endpoints * updated dtos to match casing convention. updated workout_session logic * Added functionality for workout sets and reps. (services, handlers, migrations, queries) * Addressed PR comments * Addressed PR comments --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: added clerk webhook secret (#62) * Fix/add clerkwebhook secret (#64) * fix: added clerk webhook secret * updated CRLF line endings to LF * Fix/add clerkwebhook secret (#66) * fix: added clerk webhook secret * updated CRLF line endings to LF * fix --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: wipe data on seed --------- Co-authored-by: Nicola Savino <77707655+NickSavino@users.noreply.github.com> Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: (#70) - updated workout session history endpoint - added reset_workflow script along with github action - added ingestion functionality for webhook * Feat: Setup Cloudwatch Logs for EC2 (#73) * feat: setup AWS Cloudwatch resource and updated deploy script to attach to logging --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> Co-authored-by: Aarsh Shah <86862845+AarshShah9@users.noreply.github.com>
* Small changes to dev tooling (docker/make/compose * Server: minor variable rename * Auth middleware + clerk webhook handler * Added WithTransaction to store * Removed debug logging message exposing userid * Removed docker-compose changes not relevant to PR * Renamed users.go to users.handler.go in handlers * Added documentation explaining dev bypass * Feat/calibration-endpoints (#57) * added user calibration endpoints and schema" - Added user_calibration migration - Added sqlc queries for calibration CRUD operations - added /api/users/me/calibration endpoints: GET, POST, DELETE - me endpoint now fetches user from clerk id using middleware, enhancing security - removed GET methods for user (GET /{id}, GET /) * Fixed line endings * Fixed time formatting in handler * Added NOT NULL constrain to updated_at, created_at in db table switch go dev container port to correct mapping (8080) fixed variable typo in middleware_auth.go --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Fixed syntax error on migration (#58) Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Feat/workouts api (#59) * Implemented workout and calibration schema with included sqlc queries. Updated makefile and seeding files * Regenerated SQLC to match new queries and models (workout type + workout session) * Added workout session service * Added Workout Handler Endpoint * Addressed PR comments - fixed syntax error in makefile - Fixed migration schema - fixed seeding script - added /service/helps/helpers.util file - renamed Dtos to match go standards, (Id -> ID) * Updated API endpoints * updated dtos to match casing convention. updated workout_session logic * Added functionality for workout sets and reps. (services, handlers, migrations, queries) * Addressed PR comments * Addressed PR comments --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: added clerk webhook secret (#62) * Fix/add clerkwebhook secret (#64) * fix: added clerk webhook secret * updated CRLF line endings to LF * Fix/add clerkwebhook secret (#66) * fix: added clerk webhook secret * updated CRLF line endings to LF * fix * prod fix * Seed Script: Wipe Data (#69) * Prod fix (#67) * Small changes to dev tooling (docker/make/compose * Server: minor variable rename * Auth middleware + clerk webhook handler * Added WithTransaction to store * Removed debug logging message exposing userid * Removed docker-compose changes not relevant to PR * Renamed users.go to users.handler.go in handlers * Added documentation explaining dev bypass * Feat/calibration-endpoints (#57) * added user calibration endpoints and schema" - Added user_calibration migration - Added sqlc queries for calibration CRUD operations - added /api/users/me/calibration endpoints: GET, POST, DELETE - me endpoint now fetches user from clerk id using middleware, enhancing security - removed GET methods for user (GET /{id}, GET /) * Fixed line endings * Fixed time formatting in handler * Added NOT NULL constrain to updated_at, created_at in db table switch go dev container port to correct mapping (8080) fixed variable typo in middleware_auth.go --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Fixed syntax error on migration (#58) Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * Feat/workouts api (#59) * Implemented workout and calibration schema with included sqlc queries. Updated makefile and seeding files * Regenerated SQLC to match new queries and models (workout type + workout session) * Added workout session service * Added Workout Handler Endpoint * Addressed PR comments - fixed syntax error in makefile - Fixed migration schema - fixed seeding script - added /service/helps/helpers.util file - renamed Dtos to match go standards, (Id -> ID) * Updated API endpoints * updated dtos to match casing convention. updated workout_session logic * Added functionality for workout sets and reps. (services, handlers, migrations, queries) * Addressed PR comments * Addressed PR comments --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: added clerk webhook secret (#62) * Fix/add clerkwebhook secret (#64) * fix: added clerk webhook secret * updated CRLF line endings to LF * Fix/add clerkwebhook secret (#66) * fix: added clerk webhook secret * updated CRLF line endings to LF * fix --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: wipe data on seed --------- Co-authored-by: Nicola Savino <77707655+NickSavino@users.noreply.github.com> Co-authored-by: NicolaSavino <nick.savino@arcurve.com> * fix: (#70) - updated workout session history endpoint - added reset_workflow script along with github action - added ingestion functionality for webhook * Feat: Setup Cloudwatch Logs for EC2 (#73) * feat: setup AWS Cloudwatch resource and updated deploy script to attach to logging * Increaed EC2 Tier and added elastic ip (#76) * Increaed EC2 Tier and added elastic ip * added newline to EOF * Logging Middleware (#75) * Added Logging Middleware to increase observability * small rename * Refactored user handler logic to be executed in service * Updated logging.go to adress bot comments * Updated logging middleware to forward optional http.ResponseWriter interfaces --------- Co-authored-by: NicolaSavino <nick.savino@arcurve.com> Co-authored-by: Aarsh Shah <86862845+AarshShah9@users.noreply.github.com>