fix: include source in exercise_snapshot for v2 by-date endpoint#1091
fix: include source in exercise_snapshot for v2 by-date endpoint#1091johnpena wants to merge 1 commit intoCodeWithCJ:mainfrom
Conversation
The v2 _buildExerciseEntryWithSnapshot function omitted `source` from the exercise_snapshot object. The frontend checks exercise_snapshot.source to determine whether to prepend /uploads/exercises/ to image paths. Without it, source was undefined (falsy), causing the frontend to use raw image filenames as URLs, resulting in 404s for all exercise images in the diary view.
There was a problem hiding this comment.
Code Review
This pull request updates the exercise entry history service to include the source field in the exercise snapshot. The review feedback suggests also including source_id and calories_per_hour to maintain parity with the legacy API and ensure compliance with the defined response schema.
| id: entryData.exercise_id as string, | ||
| name: exercise_name as string, | ||
| category: (category as string) ?? null, | ||
| source: (source as string) ?? null, | ||
| images: _parseJsonArray(images), |
There was a problem hiding this comment.
While adding source fixes the reported image loading issue, the exercise_snapshot is still missing source_id and calories_per_hour. These fields were present in the legacy implementation and are defined in the exerciseSnapshotResponseSchema. Including them ensures full parity with the legacy API and prevents potential regressions in the frontend.
| id: entryData.exercise_id as string, | |
| name: exercise_name as string, | |
| category: (category as string) ?? null, | |
| source: (source as string) ?? null, | |
| images: _parseJsonArray(images), | |
| id: entryData.exercise_id as string, | |
| name: exercise_name as string, | |
| category: (category as string) ?? null, | |
| source: (source as string) ?? null, | |
| source_id: (entryData.source_id as string) ?? null, | |
| calories_per_hour: (entryData.calories_per_hour as number) ?? null, | |
| images: _parseJsonArray(images), |
|
5 lines above, source_id is already sent so I don't know if sending the data twice is the right fix. I don't see where the frontend would expect it in the snapshot object. I only see it referenced like: Are you seeing image 404s? Where? |
Summary
_buildExerciseEntryWithSnapshotfunction omitssourcefrom theexercise_snapshotobjectexercise_snapshot.sourceto decide whether to prepend/uploads/exercises/to image pathssourcein the snapshot, it'sundefined(falsy), so the frontend uses raw image filenames as URLs, resulting in 404s for all exercise images in the diary viewTest plan
/uploads/exercises/prefix