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

Bug fixes to manual schedules #102

Merged
merged 4 commits into from
Mar 20, 2024
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
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