Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reefscape forms #442

Merged
merged 43 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
aefa0a7
Invented Reefscape
Tr01ler Jan 9, 2025
b61f76b
QuantitativeData and PitData filled!
Tr01ler Jan 9, 2025
6fd6ff2
quantitativeReportLayout and pitReportLayout finished!
Tr01ler Jan 14, 2025
4a35ad5
Side quest: added ComparativePercentMulti
Tr01ler Jan 16, 2025
6b32847
statslayout done
Tr01ler Jan 28, 2025
e0dbfe0
pitStatsLayout!
Tr01ler Jan 30, 2025
90838c4
Average points and badges
Tr01ler Feb 3, 2025
6a1365f
Extra badge
Tr01ler Feb 3, 2025
fc52ada
Merge pull request #436 from Decatur-Robotics/main
Tr01ler Feb 6, 2025
bcbc7cd
Added enums to the layout
Tr01ler Feb 7, 2025
74cf8af
I added the enums to layout wrong but I fixed it I think
Tr01ler Feb 7, 2025
d11afbd
I did it wrong again.
Tr01ler Feb 7, 2025
2f021f3
test
Tr01ler Feb 7, 2025
9137cab
untest
Tr01ler Feb 7, 2025
ac1bf02
Removed unnecessary cageheight thing
Tr01ler Feb 7, 2025
d28afae
Gave AutoCoralScoredLevelFour it's own special little section
Tr01ler Feb 7, 2025
e16e859
fixed a bajillion bugs
Tr01ler Feb 8, 2025
99c7156
1.1.20
gearbox4026 Feb 11, 2025
6d27abe
Merge branch 'main' into reefscape
renatodellosso Feb 11, 2025
80004e1
Bug fixes again!
Tr01ler Feb 13, 2025
e9ee3d3
Merge branch 'reefscape' of https://github.com/Decatur-Robotics/Gearb…
Tr01ler Feb 13, 2025
b963b97
Sync changes
Tr01ler Feb 13, 2025
06d0956
Prettier fixes
Tr01ler Feb 13, 2025
896165d
Order leagues
renatodellosso Feb 13, 2025
8d1ca4c
White season covers instead of black ones
renatodellosso Feb 13, 2025
b7ce795
Remove accidental files
renatodellosso Feb 13, 2025
c7072b9
Disable
renatodellosso Feb 13, 2025
940739d
Add note about auto in pit reports
renatodellosso Feb 13, 2025
0bf4dc3
Polishing
Tr01ler Feb 13, 2025
e40847b
Merge branch 'reefscape' of https://github.com/Decatur-Robotics/Gearb…
Tr01ler Feb 13, 2025
b56cac6
Fix infinite useEffect loop in useInterval
renatodellosso Feb 13, 2025
ad00cb3
Merge branch 'reefscape' of github.com:Decatur-Robotics/Gearbox into …
renatodellosso Feb 13, 2025
76cc5e0
I HATE YOU PRETTIER!
Tr01ler Feb 13, 2025
93befe4
Merge branch 'reefscape' of https://github.com/Decatur-Robotics/Gearb…
Tr01ler Feb 13, 2025
f5ece95
I have no idea why this would fix it but it's worth a shot
Tr01ler Feb 13, 2025
8c27397
Actually fix infinite useEffect loop in useInterval
renatodellosso Feb 13, 2025
574ec73
Merge branch 'reefscape' of github.com:Decatur-Robotics/Gearbox into …
renatodellosso Feb 13, 2025
0e1c245
Version update
Tr01ler Feb 13, 2025
82845e7
Merge branch 'reefscape' of https://github.com/Decatur-Robotics/Gearb…
Tr01ler Feb 13, 2025
ea4dd05
Fix formatting in comp index
renatodellosso Feb 13, 2025
d9c85db
Merge branch 'reefscape' of github.com:Decatur-Robotics/Gearbox into …
renatodellosso Feb 13, 2025
7a5e5c1
Lint fix maybe???
Tr01ler Feb 13, 2025
c57c989
Merge branch 'reefscape' of https://github.com/Decatur-Robotics/Gearb…
Tr01ler Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/forms/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default function Form(props: FormProps) {

const elements = [];

// console.log(`Block: ${rowCount}x${colCount}: ${block.flat().map(e => e.key).join(", ")}`);
//console.log(`Block: ${rowCount}x${colCount}: ${block.flat().map(e => e.key).join(", ")}`);
for (let r = 0; r < rowCount; r++) {
for (let c = 0; c < colCount; c++) {
let topRounding = "",
Expand Down
16 changes: 4 additions & 12 deletions components/stats/SmallGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,7 @@ export default function SmallGraph(props: {
};

useEffect(() => {
if (
!props.selectedReports ||
(datapoints && currentTeam === props.team && false)
)
return;
if (!props.selectedReports) return;

setDataPoints([]);
setCurrentTeam(props.team);
Expand All @@ -126,7 +122,7 @@ export default function SmallGraph(props: {
);
});
}
}, [key, currentTeam, datapoints, props.selectedReports, props.team]);
}, [key, currentTeam, props.selectedReports, props.team]);

if (!props.selectedReports) {
return <></>;
Expand All @@ -141,13 +137,9 @@ export default function SmallGraph(props: {
console.log(e.target.value);
setKey(e.target.value);
}}
defaultValue={"selected"}
>
<option
disabled
selected
>
Select Variable
</option>
<option disabled>Select Variable</option>
{keys.map((key) => (
<option
key={key}
Expand Down
28 changes: 28 additions & 0 deletions lib/Enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,31 @@ export namespace IntoTheDeepEnums {
HighLevelClimb = "High Level Climb",
}
}

export namespace ReefscapeEnums {
export enum EndgameClimbStatus {
None = "None",
Park = "Park",
High = "High",
Low = "Low",
}

export enum DriveThroughDeepCage {
No = "No",
Slow = "Slow",
Fast = "Fast",
}

export enum AutoCapabilities {
NoAuto = "No Auto",
MovePastStart = "Move Past Start",
ScoreOneCoral = "Score One Coral",
ScoreMoreThanOneCoral = "ScoreMoreThanOneCoral",
}

export enum Climbing {
No = "No",
Deep = "Deep",
Shallow = "Shallow",
}
}
18 changes: 18 additions & 0 deletions lib/Layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
CenterStageEnums,
IntoTheDeepEnums,
FtcDrivetrain,
ReefscapeEnums,
} from "./Enums";
import { PitReportData, QuantData, Pitreport, Report, League } from "./Types";

Expand Down Expand Up @@ -143,6 +144,14 @@ export type StatPair<
label: string;
};

export type StatGroup<
TPitData extends PitReportData,
TQuantData extends QuantData,
> = {
stats: Stat<TPitData, TQuantData>[];
label: string;
};

export type StatsLayout<
TPitData extends PitReportData,
TQuantData extends QuantData,
Expand Down Expand Up @@ -204,6 +213,10 @@ export function keyToType(
CenterStageEnums.AutoSidePreference,
IntoTheDeepEnums.StartedWith,
IntoTheDeepEnums.EndgameLevelClimbed,
ReefscapeEnums.AutoCapabilities,
ReefscapeEnums.Climbing,
ReefscapeEnums.DriveThroughDeepCage,
ReefscapeEnums.EndgameClimbStatus,
];

if (key === "Defense") return Defense;
Expand All @@ -213,6 +226,11 @@ export function keyToType(
if (key === "EndgameLevelClimbed")
return IntoTheDeepEnums.EndgameLevelClimbed;

if (key == "AutoCapabilities") return ReefscapeEnums.AutoCapabilities;
if (key == "Climbing") return ReefscapeEnums.Climbing;
if (key == "DriveThroughDeepCage") return ReefscapeEnums.DriveThroughDeepCage;
if (key == "EndgameClimbStatus") return ReefscapeEnums.EndgameClimbStatus;

for (const e of enums) {
if (Object.values(e).includes(exampleData[key])) return e;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export class Game<

fieldImagePrefix: string;
coverImage: string;
coverImageClass: string;

getBadges: (
pitData: Pitreport<TPitData> | undefined,
Expand Down Expand Up @@ -201,6 +202,7 @@ export class Game<
pitStatsLayout: PitStatsLayout<TPitData, TQuantData>,
fieldImagePrefix: string,
coverImage: string,
coverImageClass: string | undefined,
getBadges: (
pitData: Pitreport<TPitData> | undefined,
quantitativeReports: Report<TQuantData>[] | undefined,
Expand Down Expand Up @@ -234,6 +236,7 @@ export class Game<

this.fieldImagePrefix = fieldImagePrefix;
this.coverImage = coverImage;
this.coverImageClass = coverImageClass ?? "";

this.getBadges = getBadges;
this.getAvgPoints = getAvgPoints;
Expand Down
2 changes: 1 addition & 1 deletion lib/api/ClientApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ export default class ClientApi extends NextApiTemplate<ApiDependencies> {
isAuthorized: AccessLevels.AlwaysAuthorized,
handler: async (req, res, { tba }, authData, [tbaId]) => {
const compRankings = await tba.req.getCompetitonRanking(tbaId);
return res.status(200).send(compRankings.rankings);
return res.status(200).send(compRankings?.rankings);
},
});

Expand Down
1 change: 1 addition & 0 deletions lib/client/GameId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export enum GameId {
Crescendo = "Crescendo",
CenterStage = "CenterStage",
IntoTheDeep = "IntoTheDeep",
Reefscape = "Reefscape",
}

export const defaultGameId = GameId.Crescendo;
28 changes: 28 additions & 0 deletions lib/client/StatsMath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,31 @@ export function ComparativePercent<T extends QuantData>(

return Round((a / (b + a)) * 100) + "%";
}

/**
* @tested_by tests/lib/client/StatsMath.test.ts
*/
export function ComparativePercentMulti<T extends QuantData>(
selectors: Selector<T>[],
reports: Report<T>[],
) {
const results: string[] = [];
const totals = selectors.map((selectors) =>
NumericalTotal(selectors, reports),
);

let sum = 0;
for (let i = 0; i < totals.length; i++) {
sum += totals[i];
}

for (let i = 0; i < totals.length; i++) {
results.push(Round((totals[i] / sum) * 100) + "%");
}

if (sum === 0) {
return 0;
}

return results;
}
14 changes: 9 additions & 5 deletions lib/client/useInterval.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";

/**
* Can be janky. You've been warned.
*/

export default function useInterval(
func: () => any,
interval: number,
deps: any[] = [],
) {
const [id, setId] = useState<NodeJS.Timeout | undefined>(undefined);
const [id, setId] = useState<NodeJS.Timeout>();
const callback = useCallback(func, [func, ...deps]);

useEffect(() => {
setId(setInterval(func, interval));
return () => clearInterval(id);
}, [func.name, interval, func, id, deps]);
console.log("Setting interval", interval);
const newInterval = setInterval(callback, interval);
setId(newInterval);
return () => clearInterval(newInterval);
}, [interval, callback]);

return id;
}
Loading
Loading