Skip to content

feat(data): multi-exercise support with full backward compatibility - #1

Draft
lumachroma with Copilot wants to merge 3 commits into
mainfrom
copilot/implement-data-layer-support-multiple-exercises
Draft

feat(data): multi-exercise support with full backward compatibility#1
lumachroma with Copilot wants to merge 3 commits into
mainfrom
copilot/implement-data-layer-support-multiple-exercises

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown

Adds data layer support for tracking multiple exercises per day using a semicolon-delimited CSV format, while remaining fully backward-compatible with existing single-exercise entries and CSV files.

Data format

date,weight,calories,steps,exerciseType,exerciseMinutes
2026-05-15,78.4,2100,8450,Cycling;Walking;Strength,60;45;20
2026-05-14,78.2,2150,9200,Running,40

Internal IndexedDB representation adds an exercises array alongside the existing legacy scalar fields (populated from exercises[0] for UI compatibility):

{
  "exercises": [
    { "type": "Cycling", "minutes": "60" },
    { "type": "Walking", "minutes": "45" }
  ],
  "exerciseType": "Cycling",
  "exerciseMinutes": "60"
}

Changes

src/lib/db.js

  • parseExercises(typeString, minutesString) — splits semicolon-delimited CSV strings into { type, minutes }[]; pairs by index then filters empty types, so sparse entries like Cycling;;Strength,60;;20 are handled correctly
  • serializeExercises(exercises) — converts array back to { types, minutes } delimited strings
  • sanitizeEntry — normalizes old entries (no exercises field → built from legacy scalars) and new entries (uses array directly); always back-fills exerciseType/exerciseMinutes from exercises[0]
  • createEmptyEntryDraft — includes exercises: []
  • isEntryEmpty — extended to check exercises array

src/lib/daily-log-csv.js

  • parseEntriesCsv — parses both Running,40 and Cycling;Walking,60;45; normalizes exerciseType/exerciseMinutes to first exercise
  • serializeEntriesToCsv — serializes from exercises array; single-exercise output is unchanged
  • createDailyLogCsvTemplate — updated to show multi-exercise example row

src/components/app/DailyHistoryPage.helpers.js

  • formatExerciseSummary — renders Cycling • 60 min + Walking • 45 min; falls back to legacy scalar fields for old entries
  • hasExercise — checks exercises array first, then legacy fields

Tests

  • 33 new tests covering parseExercises/serializeExercises edge cases, multi-exercise CSV parsing, old-format backward compat, round-trip serialization, and display helpers
  • Fixtures updated to include exercises field

Copilot AI changed the title [WIP] Implement data layer support for multiple exercises per day feat(data): multi-exercise support with full backward compatibility Jul 18, 2026
Copilot AI requested a review from lumachroma July 18, 2026 11:47
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