Skip to content

Refactor rest time storage from seconds to human-readable strings - #17

Merged
benmosher merged 1 commit into
mainfrom
claude/rest-field-string-JjKS0
Mar 3, 2026
Merged

Refactor rest time storage from seconds to human-readable strings#17
benmosher merged 1 commit into
mainfrom
claude/rest-field-string-JjKS0

Conversation

@benmosher

Copy link
Copy Markdown
Owner

Summary

This PR refactors how rest times are stored in workout groups, changing from numeric seconds (restSeconds: number) to human-readable strings (rest: string). This improves data clarity and eliminates the need for parsing/formatting logic in the UI layer.

Key Changes

  • Type definition update: Changed MovementGroup.restSeconds?: number to MovementGroup.rest?: string in workout-types.ts

  • UI simplification: Removed parseRestSeconds() and formatRestSeconds() functions from WorkoutEditor.tsx and simplified the rest input handling to store/display raw string values

  • Migration logic: Added migrateRest() and migrateRestSeconds() functions in plate-db.ts to handle backward compatibility with existing workouts that use the old restSeconds numeric format

  • Export format update: Changed ExportedGroup.restSeconds?: number to ExportedGroup.rest?: string in workout-export.ts and updated packing/unpacking logic accordingly

  • Viewer simplification: Removed formatRest() function from WorkoutViewer.tsx and updated display to use the rest string directly

  • Importer update: Updated WorkoutImporter.tsx to work with the new rest string format

  • Test updates: Updated test expectations in workout-export.test.ts to reflect the new string-based rest format

Implementation Details

  • The migration logic automatically converts old numeric restSeconds values to human-readable strings (e.g., 180"3min", 90"1:30")
  • Rest values are now stored as-is without parsing, reducing complexity and potential for formatting inconsistencies
  • The change maintains backward compatibility by detecting and migrating old data during load

https://claude.ai/code/session_01Rz6TMvT8FwbYhcfFEWaDmU

Store rest as a raw user-entered string instead of parsed seconds.
Time parsing is removed from the editor and deferred to view-time.
DB migration converts legacy restSeconds numbers to readable strings.

https://claude.ai/code/session_01Rz6TMvT8FwbYhcfFEWaDmU
@benmosher
benmosher merged commit 223f115 into main Mar 3, 2026
1 check passed
@benmosher
benmosher deleted the claude/rest-field-string-JjKS0 branch March 3, 2026 13:03
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.

2 participants