BREAD5940 / frc-scouting

A TypeScript library for handling FRC scouting data from robotics tournaments
Apache License 2.0
3 stars 0 forks source link

Infinite Recharge: Improve error checking between Color Wheel and Power Cell Tracker on match creation #2

Open TheAnnalyst opened 3 years ago

TheAnnalyst commented 3 years ago

Currently, it's possible to construct an InfiniteRechargeMatch that you cannot then load from the SQL backend.

const frc = require('frc-scouting');
const backend = new frc.SQLBackend(new frc.InfiniteRecharge.InfiniteRechargeSQL(':memory:'));

const cells = new frc.InfiniteRecharge.PowerCellTracker({
    LOW: {auto: 0, teleop: 0},
    INNER: {auto: 0, teleop: 0},
    OUTER: {auto: 0, teleop: 0},
}, true);
const wheel = new frc.InfiniteRecharge.ColorWheel('SPECIFIC_COLOR');
const match = new frc.InfiniteRecharge.InfiniteRechargeMatch(1, 'test', 1, 'RED', {powerCells: cells, colorWheel: wheel}); 

backend.saveMatch(match);
backend.getMatchByNumber(1); // throws an error
TheAnnalyst commented 3 years ago

(This should be an easy bug for anyone [even new programmers, especially new programmers] to fix; it just requires moving the validation logic out of the PowerCellTracker and ColorWheel constructors, and into the InfiniteRechargeMatch constructor.)