Skip to content

fix(export): export all 14 tables, not just weights - #4

Open
eprouveze wants to merge 1 commit into
mainfrom
feat/export-all-tables
Open

fix(export): export all 14 tables, not just weights#4
eprouveze wants to merge 1 commit into
mainfrom
feat/export-all-tables

Conversation

@eprouveze

Copy link
Copy Markdown
Owner

Summary

  • The only data-export feature (Settings modal → "Export Data (JSON)") fetched /api/weights and dumped just that one table — 13 of 14 tables were completely absent from any export path.
  • Added GET /api/export, which does a plain, unfiltered db.select().from(table) per table (mirroring the query style already used by the simple per-table GET routes) and returns one JSON object keyed by table name.
  • Deliberately does not reuse /api/vo2max, /api/hrv, /api/nutrition-sprints, or /api/food-entries as-is for the export, since those endpoints apply date-window filtering, response reshaping, or (for nutrition-sprints) a side-effecting write — none of which belong in a full-data backup.
  • Wired settings-modal.tsx's handleExportData to call /api/export instead of /api/weights; same client-side blob-download UX as before (JSON file, same filename pattern).

Tables now included: weights, goals, entries, dailySteps, workouts, settings, dailySleep, restingHeartRate, workoutRoutes, bodyComposition, vo2max, heartRateVariability, nutritionSprints, foodEntries (14/14).

Verification

  • npx tsc --noEmit — zero errors (installed deps with --ignore-scripts for typecheck only; node_modules removed after, not committed).
  • Could not run the dev server or actually execute the export end-to-end: better-sqlite3's native binding does not build against this machine's Node 26 — a known pre-existing blocker, unrelated to this change. Verified by code reading + typecheck only.

Test plan

  • npm install on a machine where better-sqlite3 builds, run dev server, click Settings → Export Data, confirm the downloaded JSON has all 14 keys with expected row counts
  • Spot-check workoutRoutes[].routeData is still the raw JSON string (unparsed, same as stored) and settings returns all rows (not just one key)

🤖 Generated with Claude Code

Data export only fetched /api/weights and dumped that single table.
Schema has 14 tables total; 13 were missing from any export path
(goals, entries, dailySteps, workouts, settings, dailySleep,
restingHeartRate, workoutRoutes, bodyComposition, vo2max,
heartRateVariability, nutritionSprints, foodEntries).

Added a dedicated /api/export route that does a plain unfiltered
select per table (matching the query style of the existing per-table
GET endpoints) rather than reusing endpoints like /api/vo2max or
/api/hrv, which apply date-window filtering and response reshaping
for their own UI purposes and would produce an incomplete/derived
backup. Wired settings-modal's handleExportData to the new endpoint;
same client-side blob-download behavior as before.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@eprouveze, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 39 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 125e0e4c-8cdb-4e36-ba94-4ab6c1682595

📥 Commits

Reviewing files that changed from the base of the PR and between 1734cc0 and f773bde.

📒 Files selected for processing (2)
  • src/app/api/export/route.ts
  • src/components/dashboard/settings-modal.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/export-all-tables

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant