Skip to content

Conversation

Copy link

Copilot AI commented Feb 7, 2026

Summary

Implements TypeORM seeding script that generates 5 drivers, 1,000 telemetry packets, and 100 derived lap records for local development and testing.

Changes

Core Implementation (scripts/seed.ts)

  • Data generation: Uses generateFakeTelemetryData() to populate all 100+ TelemetryPacket fields with realistic fake sensor data
  • Lap derivation: Calculates lap statistics from groups of ~10 packets using LapController's production logic (power metrics, distance, battery stats)
  • FK constraint handling: Deletes/inserts in dependency order (Lap → TelemetryPacket → Driver)
  • Batch processing: Inserts packets in batches of 100 to avoid overwhelming TimescaleDB
  • Temporal realism: Sequential timestamps starting 2 hours ago, 1-second intervals

Data Mapping

Maps nested ITelemetryData structure to flat TelemetryPacket entity:

// ITelemetryData has nested structure
data.Battery.Input12V  packet.Input12v
data.MotorDetails0.Supply15V  packet.Motor0Supply15v
data.BatteryFaults.Errors.PowerSupply12VFault  packet.ErrorPowerSupply12vFault

Supporting Changes

  • Added seed script to root package.json using tsx for direct TypeScript execution
  • Created scripts/README.md with prerequisites and usage documentation
  • Added scripts/*.ts to .eslintignore (not included in tsconfig project references)

Usage

yarn db:up && yarn migrate:run && yarn seed

Script is idempotent - clears all data before seeding.

Notes

  • Casing mismatch exists between shared functions (uppercase V: Input12V) and entity fields (lowercase v: Input12v) - script uses entity field names as source of truth
  • NetPowerOut calculation matches LapController: powerIn - powerOut (net energy gained, not consumed)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ofcncog2cu-dsn.algolia.net
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/yarn add tsx -D (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Create a seeding script for laps and telemetry packets (development/test only)</issue_title>
<issue_description>## Overview
Create a TypeORM seeding script for the database, focused on development and test environments, to populate the Lap and TelemetryPacket tables. This script should:

  • Reference the generateFakeTelemetryData() from packages/shared/src/functions.ts to generate 1,000 packets and 100 lap packets.
  • Generate and persist related entity records as required by foreign keys (i.e., Lap, Driver, TelemetryPacket, etc. – see schemas below).
  • Clear all relevant tables (Lap, TelemetryPacket, and referenced entities) before seeding, ensuring idempotency.
  • Be runnable as a CLI script, and registered as a script entry in package.json (e.g., npm run seed).
  • Assist dev/test only; not intended for production data.

Implementation Plan

  1. Analyze Entity Schemas: Review entity definitions for Lap, TelemetryPacket, Driver, etc.:
  2. Set Up Script Structure: Create a new script (e.g., seed.ts or seed.js) in a logical place (e.g., scripts/ or top-level)
    • Connect to the database using TypeORM config.
  3. Data Generation:
    • Use generateFakeTelemetryData() for fake packet data.
    • Define constants for 1,000 TelemetryPacket objects and 100 Lap entries, referencing each other as appropriate.
    • Create related entities if required (e.g., create fake Driver records if required by Lap/Packet FK).
  4. Clear Existing Data:
    • Before inserting new records, delete data from Lap, TelemetryPacket, and all related tables (dependency order!).
    • Goal: script must be idempotent and avoid duplicating data on repeated runs.
  5. Seed Data:
    • Insert related entities (parents first), 100 Laps, and 1,000 TelemetryPackets.
  6. Script Integration:
    • Add an entry (e.g., "seed": "ts-node scripts/seed.ts") to package.json.
  7. Testing:
    • Test script on a local development DB.

Questions

  • Please confirm if the Lap and Packet seeds should have any specific relationship or if random assignment is OK? refer to the LapController.ts file in how the RFID and Timestamp of the lapData packet to see the relationship of data. typically we would create the packets first, then derive the lapData from the packets. We might have 1 lap packet for every 10 telemetry packets or something like that.

  • Confirm: create at least the referenced Driver (or other FK) entities if not present?
    Yes.

References


Copilot will proceed to implementation details after your confirmation, or if you answer the above questions.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link

vercel bot commented Feb 7, 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:57pm

Copilot AI and others added 3 commits February 7, 2026 18:51
Co-authored-by: justin-phxm <113923596+justin-phxm@users.noreply.github.com>
Co-authored-by: justin-phxm <113923596+justin-phxm@users.noreply.github.com>
Co-authored-by: justin-phxm <113923596+justin-phxm@users.noreply.github.com>
Copilot AI changed the title [WIP] Add seeding script for laps and telemetry packets Add database seeding script for development/test environments Feb 7, 2026
Copilot AI requested a review from justin-phxm February 7, 2026 18:57
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.

Create a seeding script for laps and telemetry packets (development/test only)

2 participants