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

All team functions working #78

Merged
merged 4 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions replit.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ pkgs }: {
deps = [
pkgs.nodejs-16_x
pkgs.cowsay
];
}
3 changes: 1 addition & 2 deletions src/admin/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ router.get("/enterMatch", async (req,res) => {
if (scouter.state.status == ScoutingSync.SCOUTER_STATUS.WAITING)
scouter.socket.emit("enterMatch");
}

//res.json();
res.json();
}
})
router.post("/setMatch", (req,res) => {
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/modules/SingleDisplay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class SingleDisplay {

/**
*
* @param {*an alliance of any length*} alliance1
* @param {*an allaicne of any length*} alliance1
* @param {*an alliance to compare to of any length*} alliance2
* @param {*the data set that holds the infomation of the teams*} dataset
* @returns {*the avg difference in score between allaicne 1 and allaicne 2*}
Expand Down
3 changes: 2 additions & 1 deletion src/analysis/public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ body {
grid-area: 3 / 1 / 4 / 2;
background-color: var(--bg-alt);
padding: 16px;
/* height:100vw; this messes with the search bar*/
height: calc(100vh - 75px);
overflow: auto;
display: grid;
min-height: 0;
grid-template-rows: auto auto 1fr;
Expand Down
15 changes: 12 additions & 3 deletions src/analysis/public/js/autoPick.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@




// const { Dataset } = require("../../DataTransformer");
// const { zScore, cumulativeStdNormalProbability } = require("simple-statistics");

Expand Down Expand Up @@ -343,4 +341,15 @@ console.log(allianceAverage(allianceRed))
console.log(allianceStandardDeviation(allianceBlue))
console.log(allianceStandardDeviation(allianceRed))

console.log(compareAlliances(allianceBlue, allianceRed));
console.log(compareAlliances(allianceBlue, allianceRed));

let teams = [teamB1, teamB2, teamB3, teamR1, teamR2, teamR3]
compareAllTeams(teams)
console.log(teamB1.avgProbability) // 0.66152 (avg: 80, sd: 20)
console.log(teamB2.avgProbability) // 0.59114 (avg: 70, sd: 20)
console.log(teamB3.avgProbability) // 0.2696 (avg: 20, sd: 20)
console.log(teamR1.avgProbability) // 0.52532 (avg: 60, sd: 20)
console.log(teamR2.avgProbability) // 0.59114 (avg: 70, sd: 20)
console.log(teamR3.avgProbability) // 0.36126 (avg: 30, sd: 20)

*/
51 changes: 25 additions & 26 deletions src/analysis/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,36 @@ router.get("/csv", async (req,res) => {

//create rows
let rows = [];
let headerRow = true;
let checkData = function(team){
if(Object.entries(team).filter(([key,value])=>key!="manual").length == 0){
return false
}
return true
}

for (let [teamNumber,team] of Object.entries(dataset.teams).filter(([num,team])=>checkData(team)) ) {
if(headerRow){
headerRow = false;
rows.push(["Team #",
...Object.entries(team.averages).filter(([key,value])=>!isNaN(value)&&value).map(([i,x]) => i+" Average"), //all averages
...Object.entries(team.averageScores).filter(item=>!isNaN(item)).map(([i,x]) => i+" Score Average"), //all averages
"Average Cycle",
"Average Completed Cycle"
let headerRow = false;
for (let [teamNumber,team] of Object.entries(dataset.teams) ) {
console.log(team.counts)
if (!headerRow) {
headerRow = true;
rows.push(["Team Number",
...Object.entries(team.counts).map(([i,x]) => i+" Count"), //all counts
...Object.entries(team.averages).map(([i,x]) => i+" Average"), //all averages
...Object.entries(team.averageScores).map(([i,x]) => i+" Average Score"), //average scores
"Time Per Ball",
"Possible Climbs",
"Accuracy", //accuracy,
...Object.entries(team.averageScores).map(([i,x]) => i+"Average"), //all averages
])
}
rows.push([teamNumber,
...Object.entries(team.counts).map(([i,x]) => x), //all counts
...Object.entries(team.averages).map(([i,x]) => x), //all averages
...Object.entries(team.averageScores).map(([i,x]) => x), //all averages
team.timePerBall,
team.possibleClimbs,
team.accuracy, //accuracy
...Object.entries(team.averageScores).map(([i,x]) => x), //all averages
])
}
rows.push([teamNumber,
...Object.entries(team.averages).filter(([key,value])=>!isNaN(value)&&value).map(([i,x]) => x), //all averages
...Object.entries(team.averageScores).filter(item=>!isNaN(item)).map(([i,x]) => x), //all averages
team.cycle.averageTime,
team.cycle.averageTimeComplete
])

}
}

//make into csv
let csv = rows.map(row => row.reduce((acc,value) => acc+`,${value}`)).reduce((acc,row) => acc+`${row}\n`, "");
res.set({"Content-Disposition":`attachment; filename="teams.csv"`});
res.send(csv);
})
})

module.exports = router;