Skip to content

Update RaceTab and lapdata to use timescale#279

Merged
justin-phxm merged 2 commits intomainfrom
Update-RaceTab-with-Timescale
Feb 7, 2026
Merged

Update RaceTab and lapdata to use timescale#279
justin-phxm merged 2 commits intomainfrom
Update-RaceTab-with-Timescale

Conversation

@alexwhelan12
Copy link
Contributor

@alexwhelan12 alexwhelan12 commented Jan 31, 2026

Summary by CodeRabbit

  • Refactor

    • Lap data now uses a flattened field structure for consistency across the app, aligning displayed lap values.
  • UI Changes

    • Table cell layout updated with sticky positioning and improved padding for more stable column visibility.
  • Behavior

    • Default table sorting now uses the TimeStamp field for initial ordering.

@alexwhelan12 alexwhelan12 requested a review from a team as a code owner January 31, 2026 23:05
@vercel
Copy link

vercel bot commented Jan 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
helios-telemetry Ready Ready Preview, Comment Feb 7, 2026 6:19pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 31, 2026

📝 Walkthrough

Walkthrough

This PR flattens lap data from a nested data object to top-level fields (e.g., TimeStamp, AmpHours, LapTime, TotalPowerIn/Out, NetPowerOut) and updates all consumers: shared types, server emission, client store, table config, and UI components to the new shape.

Changes

Cohort / File(s) Summary
Shared Types
packages/shared/src/types.ts
Replace nested data object with flat top-level lap fields (AmpHours, AveragePackCurrent, AverageSpeed, BatterySecondsRemaining, Distance, EnergyConsumed, LapTime, NetPowerOut, TimeStamp, TotalPowerIn, TotalPowerOut) for ILapData and IFormattedLapData.
Server — Lap emission
packages/server/src/controllers/LapController/LapController.ts
Construct and emit/insert lap objects using the new flat fields; docs updated from DynamoDB → TimescaleDB; removed legacy nested data wrapper.
Client — Store & formatting
packages/client/src/stores/useLapData.ts
formatLapData now outputs flat top-level fields (rounded numeric values); removed nested data and timestamp; fetchLapData formats laps before setting state; setLapData removed from public state.
Client — Table & UI
packages/client/src/components/config/lapTableConfig.ts, packages/client/src/components/tabs/RaceTab.tsx, packages/client/src/components/molecules/RaceTabMolecules/RaceTabTable.tsx
Updated column accessors from "data.X" to "X" (e.g., TimeStamp), adjusted default sort key to TimeStamp, removed fetchLapData from destructuring, and fixed a td className to include sticky/layout classes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • burtonjong
  • justin-phxm
  • promatty

"i hopped through code with ears held high,
Flattened fields now greet the sky.
TimeStamp sits proud at the top, you see —
AmpHours, LapTime, and friends run free.
🐇✨"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references updating RaceTab and lapdata for Timescale, which aligns with the core changes: flattening the data structure from nested objects to top-level fields across the lap data flow.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Update-RaceTab-with-Timescale

No actionable comments were generated in the recent review. 🎉


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 and usage tips.

@alexwhelan12 alexwhelan12 reopened this Jan 31, 2026
@alexwhelan12 alexwhelan12 changed the title fix: update types of fetched lap data Update RaceTab and lapdata to use timescale Jan 31, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/client/src/components/config/lapTableConfig.ts (1)

11-38: ⚠️ Potential issue | 🟡 Minor

TimeStamp sorting relies on hardcoded date format parsing.

The custom sortingFn parses dates assuming a specific format (MM/DD/YYYY HH:MM) that matches toLocaleString("en-US") output. However, toLocaleString("en-US") actually produces format like "1/31/2026, 3:05:08 PM" which includes:

  • Commas
  • AM/PM indicator
  • Seconds

The current parser will fail or produce incorrect results with this format.

🐛 Proposed fix using Date constructor directly
     sortingFn: (rowA, rowB, columnId) => {
-      const parseDate = (dateString: string) => {
-        const parts = dateString.split(" ");
-
-        const dateParts = parts[0]?.split("/");
-        const timeParts = parts[1]?.split(":");
-
-        if (!dateParts || !timeParts) {
-          throw new Error("Invalid Time");
-        }
-        const hour = Number(timeParts[0]);
-        const minute = Number(timeParts[1]);
-
-        const day = Number(dateParts[1]);
-        const month = Number(dateParts[0]);
-        const year = Number(dateParts[2]);
-        return new Date(year, month - 1, day, hour, minute).getTime();
-      };
-      const dateA = parseDate(rowA.getValue(columnId));
-      const dateB = parseDate(rowB.getValue(columnId));
+      const dateA = new Date(rowA.getValue(columnId)).getTime();
+      const dateB = new Date(rowB.getValue(columnId)).getTime();

       return dateB - dateA;
     },
packages/shared/src/types.ts (1)

436-476: ⚠️ Potential issue | 🟡 Minor

Remove or repurpose the unused LapData class.

The LapData class is exported but never imported or instantiated anywhere in the codebase—it appears to be dead code. All active usage is of the ILapData interface instead. Additionally, there are naming inconsistencies between the class (camelCase: timestamp, lapTime, etc.) and the interface (PascalCase: TimeStamp, LapTime, etc.), and field mismatches (lapNumber and lapsRemaining exist only in the class; Rfid exists only in the interface).

Either remove the class if it's no longer needed, or if it's intended for future use, align it with ILapData to prevent confusion.

🤖 Fix all issues with AI agents
In `@packages/client/src/components/molecules/RaceTabMolecules/RaceTabTable.tsx`:
- Line 53: In the RaceTabTable component update the JSX className string (the
className prop that includes `${cell.id.includes("TimeStamp") ? "left-0 z-10" :
""}`) to fix the typo by replacing "w-fullpx-4" with two separate Tailwind
classes "w-full px-4" so the utility classes are correctly parsed.
🧹 Nitpick comments (1)
packages/client/src/stores/useLapData.ts (1)

19-19: Consider making locale configurable for internationalization.

The hardcoded "en-US" locale may not be appropriate for all users. If internationalization is planned, consider using the user's browser locale or a configurable setting.

TimeStamp: new Date(lapPacket.TimeStamp).toLocaleString(),

justin-phxm
justin-phxm previously approved these changes Feb 7, 2026
Copy link
Collaborator

@justin-phxm justin-phxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@justin-phxm justin-phxm merged commit b2e518c into main Feb 7, 2026
8 checks passed
@justin-phxm justin-phxm deleted the Update-RaceTab-with-Timescale branch February 7, 2026 18:21
@coderabbitai coderabbitai bot mentioned this pull request Feb 7, 2026
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.

3 participants

Comments