From cc0acd6814db10b25c68a723cf74f3fc32afb7e0 Mon Sep 17 00:00:00 2001 From: anvar Date: Sat, 9 Dec 2023 11:26:08 +0300 Subject: [PATCH 1/2] add score-scout stubs --- .../routers/epja-2023-2/score-scout/index.js | 69 ++++ .../score-scout/tournament-empty.json | 109 ++++++ .../epja-2023-2/score-scout/tournament.json | 335 ++++++++++++++++++ .../score-scout/tournaments_active.json | 19 + .../score-scout/tournaments_archived.json | 61 ++++ 5 files changed, 593 insertions(+) create mode 100644 server/routers/epja-2023-2/score-scout/index.js create mode 100644 server/routers/epja-2023-2/score-scout/tournament-empty.json create mode 100644 server/routers/epja-2023-2/score-scout/tournament.json create mode 100644 server/routers/epja-2023-2/score-scout/tournaments_active.json create mode 100644 server/routers/epja-2023-2/score-scout/tournaments_archived.json diff --git a/server/routers/epja-2023-2/score-scout/index.js b/server/routers/epja-2023-2/score-scout/index.js new file mode 100644 index 0000000..c8948f2 --- /dev/null +++ b/server/routers/epja-2023-2/score-scout/index.js @@ -0,0 +1,69 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const express = require("express"); +const router = express.Router(); + +router.use(express.json()); + +module.exports = router; + +let tournamentsActiveActivated = true; +let tournamentsArchivedActivated = true; +let tournamentActivated = true; + +router.get("/tournaments/active", (req, res) => { + if (tournamentsActiveActivated) { + res.status(200).send(require("./tournaments_active.json")); + } else { + res.status(500).send(); + } +}); + +router.get("/tournaments/active/toggle", (req, res) => { + tournamentsActiveActivated = !tournamentsActiveActivated; + res.send(tournamentsActiveActivated ? "Activated" : "Deactivated"); +}); + +router.get("/tournaments/archived", (req, res) => { + if (tournamentsArchivedActivated) { + res.status(200).send(require("./tournaments_archived.json")); + } else { + res.status(500).send(); + } +}); + +router.get("/tournaments/archived/toggle", (req, res) => { + tournamentsArchivedActivated = !tournamentsArchivedActivated; + res.send(tournamentsArchivedActivated ? "Activated" : "Deactivated"); +}); + +router.get("/tournaments/:id", (req, res) => { + id = req.params.id; + if (tournamentActivated) { + if (id === "2") { + res.status(200).send(require("./tournament-empty.json")); + } else { + res.status(200).send(require("./tournament.json")); + } + } else { + res.status(500).send(); + } +}); + +router.get("/tournaments/:id/toggle", (req, res) => { + tournamentActivated = !tournamentActivated; + res.send(tournamentActivated ? "Activated" : "Deactivated"); +}); + +router.post("/tournaments/:id", (req, res) => { + const data = req.body; + + if (data === undefined) { + return res.status(400).send("Bad Request: No data provided"); + } + + try { + res.status(200).send("Data successfully written to file"); + } catch (error) { + res.status(500).send("Internal Server Error"); + } +}); diff --git a/server/routers/epja-2023-2/score-scout/tournament-empty.json b/server/routers/epja-2023-2/score-scout/tournament-empty.json new file mode 100644 index 0000000..d46e1b1 --- /dev/null +++ b/server/routers/epja-2023-2/score-scout/tournament-empty.json @@ -0,0 +1,109 @@ +{ + "title": "Fall Students Tournament", + "amountGamesPlayed": 90, + "date": "2020-11-30", + "isFinished": false, + "isRatingSystem": false, + "players": [ + { "name": "Kailee Escamilla" }, + { "name": "Chiara Shultz" }, + { "name": "Jensen Hillman" }, + { "name": "Marques Cotter" }, + { "name": "Dequan Harms" }, + { "name": "Alexcia Gaston" }, + { "name": "Bruno Smalley" }, + { "name": "Dorian Fenton" }, + { "name": "Brian Thorpe" }, + { "name": "Laura Raymond" }, + { "name": "Ireland Acuna" }, + { "name": "Mallory Whitaker" }, + { "name": "Cinthia Garibay" }, + { "name": "Teresa Tong" }, + { "name": "Santana Custer" }, + { "name": "Shemar Sander" } + ], + "firstStage": { + "type": "bracket", + "players": [ + { + "name": "Kailee Escamilla", + "id": 0 + }, + { + "name": "Chiara Shultz", + "id": 1 + }, + { + "name": "Jensen Hillman", + "id": 2 + }, + { + "name": "Marques Cotter", + "id": 3 + }, + { + "name": "Dequan Harms", + "id": 4 + }, + { + "name": "Alexcia Gaston", + "id": 5 + }, + { + "name": "Bruno Smalley", + "id": 6 + }, + { + "name": "Dorian Fenton", + "id": 7 + }, + { + "name": "Brian Thorpe", + "id": 8 + }, + { + "name": "Laura Raymond", + "id": 9 + }, + { + "name": "Ireland Acuna", + "id": 10 + }, + { + "name": "Mallory Whitaker", + "id": 11 + }, + { + "name": "Cinthia Garibay", + "id": 12 + }, + { + "name": "Teresa Tong", + "id": 13 + }, + { + "name": "Santana Custer", + "id": 14 + }, + { + "name": "Shemar Sander", + "id": 15 + } + ], + "stages": [ + { + "matchIds": [0, 1, 2, 3, 4, 5, 6, 7] + }, + { + "matchIds": [8, 9, 10, 11] + }, + { + "matchIds": [12, 13] + }, + { + "matchIds": [14] + } + ], + "matches": [] + } +} diff --git a/server/routers/epja-2023-2/score-scout/tournament.json b/server/routers/epja-2023-2/score-scout/tournament.json new file mode 100644 index 0000000..d34ba65 --- /dev/null +++ b/server/routers/epja-2023-2/score-scout/tournament.json @@ -0,0 +1,335 @@ +{ + "title": "Fall Students Tournament", + "amountGamesPlayed": 90, + "date": "2020-11-30", + "isFinished": false, + "isRatingSystem": false, + "players": [ + { "name": "Kailee Escamilla" }, + { "name": "Chiara Shultz" }, + { "name": "Jensen Hillman" }, + { "name": "Marques Cotter" }, + { "name": "Dequan Harms" }, + { "name": "Alexcia Gaston" }, + { "name": "Bruno Smalley" }, + { "name": "Dorian Fenton" }, + { "name": "Brian Thorpe" }, + { "name": "Laura Raymond" }, + { "name": "Ireland Acuna" }, + { "name": "Mallory Whitaker" }, + { "name": "Cinthia Garibay" }, + { "name": "Teresa Tong" }, + { "name": "Santana Custer" }, + { "name": "Shemar Sander" } + ], + "firstStage": { + "type": "bracket", + "players": [ + { + "name": "Kailee Escamilla", + "id": 0 + }, + { + "name": "Chiara Shultz", + "id": 1 + }, + { + "name": "Jensen Hillman", + "id": 2 + }, + { + "name": "Marques Cotter", + "id": 3 + }, + { + "name": "Dequan Harms", + "id": 4 + }, + { + "name": "Alexcia Gaston", + "id": 5 + }, + { + "name": "Bruno Smalley", + "id": 6 + }, + { + "name": "Dorian Fenton", + "id": 7 + }, + { + "name": "Brian Thorpe", + "id": 8 + }, + { + "name": "Laura Raymond", + "id": 9 + }, + { + "name": "Ireland Acuna", + "id": 10 + }, + { + "name": "Mallory Whitaker", + "id": 11 + }, + { + "name": "Cinthia Garibay", + "id": 12 + }, + { + "name": "Teresa Tong", + "id": 13 + }, + { + "name": "Santana Custer", + "id": 14 + }, + { + "name": "Shemar Sander", + "id": 15 + } + ], + "stages": [ + { + "matchIds": [0, 1, 2, 3, 4, 5, 6, 7] + }, + { + "matchIds": [8, 9, 10, 11] + }, + { + "matchIds": [12, 13] + }, + { + "matchIds": [14] + } + ], + "matches": [ + { + "type": "withScore", + "firstPlayer": { + "name": "Kailee Escamilla", + "id": 0 + }, + "secondPlayer": { + "name": "Shemar Sander", + "id": 15 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 2, + "secondPlayerScore": 0 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Dorian Fenton", + "id": 7 + }, + "secondPlayer": { + "name": "Brian Thorpe", + "id": 8 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 0, + "secondPlayerScore": 2 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Marques Cotter", + "id": 3 + }, + "secondPlayer": { + "name": "Cinthia Garibay", + "id": 12 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 0, + "secondPlayerScore": 3 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Dequan Harms", + "id": 4 + }, + "secondPlayer": { + "name": "Mallory Whitaker", + "id": 11 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 3, + "secondPlayerScore": 0 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Chiara Shultz", + "id": 1 + }, + "secondPlayer": { + "name": "Santana Custer", + "id": 14 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 0, + "secondPlayerScore": 2 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Bruno Smalley", + "id": 6 + }, + "secondPlayer": { + "name": "Laura Raymond", + "id": 9 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 2, + "secondPlayerScore": 0 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Jensen Hillman", + "id": 2 + }, + "secondPlayer": { + "name": "Teresa Tong", + "id": 13 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 1, + "secondPlayerScore": 2 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Alexcia Gaston", + "id": 5 + }, + "secondPlayer": { + "name": "Ireland Acuna", + "id": 10 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 2, + "secondPlayerScore": 1 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Kailee Escamilla", + "id": 0 + }, + "secondPlayer": { + "name": "Brian Thorpe", + "id": 8 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 0, + "secondPlayerScore": 3 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Cinthia Garibay", + "id": 12 + }, + "secondPlayer": { + "name": "Dequan Harms", + "id": 4 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 3, + "secondPlayerScore": 0 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Santana Custer", + "id": 14 + }, + "secondPlayer": { + "name": "Bruno Smalley", + "id": 6 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 3, + "secondPlayerScore": 1 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Teresa Tong", + "id": 13 + }, + "secondPlayer": { + "name": "Alexcia Gaston", + "id": 5 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 3, + "secondPlayerScore": 0 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Brian Thorpe", + "id": 8 + }, + "secondPlayer": { + "name": "Cinthia Garibay", + "id": 12 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 3, + "secondPlayerScore": 2 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Santana Custer", + "id": 14 + }, + "secondPlayer": { + "name": "Teresa Tong", + "id": 13 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 1, + "secondPlayerScore": 3 + }, + { + "type": "withScore", + "firstPlayer": { + "name": "Brian Thorpe", + "id": 8 + }, + "secondPlayer": { + "name": "Teresa Tong", + "id": 13 + }, + "isFinished": true, + "isStarted": true, + "firstPlayerScore": 3, + "secondPlayerScore": 0 + } + ] + } +} diff --git a/server/routers/epja-2023-2/score-scout/tournaments_active.json b/server/routers/epja-2023-2/score-scout/tournaments_active.json new file mode 100644 index 0000000..13f3e1d --- /dev/null +++ b/server/routers/epja-2023-2/score-scout/tournaments_active.json @@ -0,0 +1,19 @@ +{ + "ok": true, + "data": [ + { + "title": "Fall Students Tournament", + "amountPlayers": 32, + "amountGamesPlayed": 124, + "status": "In Progress", + "date": "2023-10-22" + }, + { + "title": "Fall Students Tournament", + "amountPlayers": 32, + "amountGamesPlayed": 124, + "status": "In Progress", + "date": "2023-10-22" + } + ] +} diff --git a/server/routers/epja-2023-2/score-scout/tournaments_archived.json b/server/routers/epja-2023-2/score-scout/tournaments_archived.json new file mode 100644 index 0000000..8bb8d9c --- /dev/null +++ b/server/routers/epja-2023-2/score-scout/tournaments_archived.json @@ -0,0 +1,61 @@ +{ + "ok": true, + "data": [ + { + "title": "1st Archived Tournament", + "amountPlayers": 9999, + "amountGamesPlayed": 80, + "status": "Finished", + "date": "2005-12-04" + }, + { + "title": "2nd Archived Tournament", + "amountPlayers": 10, + "amountGamesPlayed": 80, + "status": "Finished", + "date": "2005-12-04" + }, + { + "title": "3rd Archived Tournament", + "amountPlayers": 4, + "amountGamesPlayed": 6, + "status": "Finished", + "date": "2023-11-11" + }, + { + "title": "4th Archived Tournament", + "amountPlayers": 4, + "amountGamesPlayed": 6, + "status": "Finished", + "date": "2023-11-11" + }, + { + "title": "5th Archived Tournament", + "amountPlayers": 4, + "amountGamesPlayed": 6, + "status": "Finished", + "date": "2023-11-11" + }, + { + "title": "6th Archived Tournament", + "amountPlayers": 4, + "amountGamesPlayed": 6, + "status": "Finished", + "date": "2023-11-11" + }, + { + "title": "7th Archived Tournament", + "amountPlayers": 4, + "amountGamesPlayed": 6, + "status": "Finished", + "date": "2023-11-11" + }, + { + "title": "8th Archived Tournament", + "amountPlayers": 4, + "amountGamesPlayed": 6, + "status": "Finished", + "date": "2023-11-11" + } + ] +} From 839d0b377a2f07a9fe665d7b0ee89990b6eef259 Mon Sep 17 00:00:00 2001 From: anvar Date: Sat, 9 Dec 2023 11:44:05 +0300 Subject: [PATCH 2/2] add route to score-scout --- server/routers/epja-2023-2/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/routers/epja-2023-2/index.js b/server/routers/epja-2023-2/index.js index c46fe4a..ccb9214 100644 --- a/server/routers/epja-2023-2/index.js +++ b/server/routers/epja-2023-2/index.js @@ -4,5 +4,6 @@ const router = express.Router() router.use('/example', require('./example/index')) router.use('/pen-plotter', require('./pen-plotter/index')) +router.use('/score-scout', require('./score-scout/index')) module.exports = router