Skip to content

Commit

Permalink
Bug fixes to manual schedules (#102)
Browse files Browse the repository at this point in the history
* bug fixes
* reset teams list when assigning
  • Loading branch information
Allybe authored Mar 20, 2024
1 parent 2e9dc50 commit 141882d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
21 changes: 10 additions & 11 deletions src/admin/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,18 @@ router.post("/setMatch", (req,res) => {

router.get("/matches", async (req,res) => {

let manualSchedule = getManualMatches()
let manualSchedule = getManualMatches();

if(manualSchedule === {}){

res.json({
"allMatches": manualSchedule,
"currentMatch": ScoutingSync.match
})
if(manualSchedule.length === 0){
res.json({
"allMatches": await ScoutingSync.getMatches(),
"currentMatch": ScoutingSync.match
});
} else {
res.json({
"allMatches": await ScoutingSync.getMatches(),
"currentMatch": ScoutingSync.match
})
res.json({
"allMatches": manualSchedule,
"currentMatch": ScoutingSync.match
});
}
})
module.exports = router;
2 changes: 1 addition & 1 deletion src/schedule/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { unwatchFile } = require("fs");

express = require("express");

var schedule = {};
var schedule = [];
var tempTeams = [];

let router = express.Router();
Expand Down
13 changes: 11 additions & 2 deletions src/scouting/scouting-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,18 @@ class ScoutingSync {
if (!config.secrets.TBA_API_KEY) {
return []; //no key, no matches
}

let tbaMatches = (await axios.get(`https://www.thebluealliance.com/api/v3/event/${config.TBA_EVENT_KEY}/matches`, {
headers: {
"X-TBA-Auth-Key": config.secrets.TBA_API_KEY
}
}).catch(e => console.log(e,chalk.bold.red("\nError fetching matches from Blue Alliance Api!")))).data;
}).catch(e => console.log(e,chalk.bold.red("\nError fetching matches from Blue Alliance Api!"))));

if (tbaMatches === undefined) {
return [];
} else {
tbaMatches = tbaMatches.data;
}

//determine match numbers linearly (eg. if there are 10 quals, qf1 would be match 11)
const matchLevels = ["qm", "ef", "qf", "sf", "f"];
Expand Down Expand Up @@ -126,7 +133,9 @@ class ScoutingSync {
for (let scouter of ScoutingSync.scouters) {
if (scouter.state.connected && scouter.state.status === ScoutingSync.SCOUTER_STATUS.WAITING) {
//check to see if nextRobots is empty, if so repopulate it with all the robots in the match
if (nextRobots.size === 0) new Set(ScoutingSync.match.robots.red.concat(ScoutingSync.match.robots.blue));
if (nextRobots.size >= 0) {
nextRobots = new Set(ScoutingSync.match.robots.red.concat(ScoutingSync.match.robots.blue));
}

//get the next robot number from the set (the set doesnt return robots in any particular order)
let robotNumber = [...nextRobots][0]
Expand Down

0 comments on commit 141882d

Please sign in to comment.