Skip to content

fix(import): accept documented exercise CSV aliases#210

Open
Xmemo wants to merge 1 commit into
Snouzy:mainfrom
Xmemo:fix/exercise-csv-aliases
Open

fix(import): accept documented exercise CSV aliases#210
Xmemo wants to merge 1 commit into
Snouzy:mainfrom
Xmemo:fix/exercise-csv-aliases

Conversation

@Xmemo

@Xmemo Xmemo commented Jun 30, 2026

Copy link
Copy Markdown

Summary

Fixes #167 by making the exercise CSV importer accept the values already documented in the CSV generation prompt.

What changed

  • Added normalizeExerciseAttributeValue(attributeName, value) for importer-safe attribute value normalization.
  • Added attribute-aware aliases:
    • PRIMARY_MUSCLE / SECONDARY_MUSCLE: CORE -> ABDOMINALS
    • EQUIPMENT: BODYWEIGHT -> BODY_ONLY
    • EQUIPMENT: RESISTANCE_BAND -> BANDS
    • TYPE: FLEXIBILITY -> STRETCHING
  • Kept existing N/A-like handling (N/A, NA, NONE, NULL, empty string -> NA).
  • Improved unknown attribute value errors so the log includes the attribute name, bad value, and useful examples.
  • Updated the CSV generation prompt to prefer canonical schema values while documenting accepted aliases.
  • Added a focused assertion script for the normalization behavior.

Why

The CSV prompt previously told users or LLMs to generate values like CORE, but ExerciseAttributeValueEnum uses ABDOMINALS. That mismatch makes self-hosted custom exercise imports fail or silently lose useful muscle attributes.

Testing

Passed:

  • pnpm exec tsx scripts/import-exercise-attribute-values.test.ts
  • pnpm exec eslint scripts/import-exercise-attribute-values.ts scripts/import-exercise-attribute-values.test.ts scripts/import-exercises-with-attributes.ts
  • git diff --check HEAD~1 HEAD

Checked but not clean on current base:

  • pnpm exec tsc --noEmit --pretty false fails on existing public image module imports such as @public/logo.png, @public/images/trophy.png, and equipment images.
  • pnpm lint fails on existing unrelated import/order and unused React warnings/errors across the app. The files touched by this PR pass the targeted ESLint command above.

Not run:

  • Full CSV import against PostgreSQL. The importer requires a configured DATABASE_URL; this PR verifies the normalization layer directly and keeps database behavior unchanged.

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

@Xmemo is attempting to deploy a commit to the Workoutcool Team Team on Vercel.

A member of the Team first needs to authorize it.

@Xmemo Xmemo marked this pull request as ready for review June 30, 2026 02:49
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.

No exercises found. Try to change your equipment or muscles selection.

1 participant