Speed up loading teams
parent
18628e3fe5
commit
05473e07ad
|
@ -166,7 +166,7 @@ CATEGORIES.push(new Category(
|
|||
CATEGORIES.push(new Category(
|
||||
"teams",
|
||||
async function getTeams() {
|
||||
return await Data.getTeams();
|
||||
return await (await fetch('/fetch/manage/teams')).json();
|
||||
},
|
||||
async function listTeamHeaders() {
|
||||
const headerRow = document.createElement('tr');
|
||||
|
@ -194,8 +194,8 @@ CATEGORIES.push(new Category(
|
|||
row.appendChild(spacerCell);
|
||||
|
||||
const sportCell = document.createElement('td');
|
||||
Data.getSportName(team.sportID)
|
||||
.then(data => sportCell.textContent = data);
|
||||
let sportName = team.sport.name;
|
||||
sportCell.textContent = sportName;
|
||||
row.appendChild(sportCell);
|
||||
},
|
||||
async function addTeam() {
|
||||
|
|
|
@ -136,4 +136,14 @@ router.get('/manage/divisions', async function (req, res, next) {
|
|||
res.json(data);
|
||||
});
|
||||
|
||||
router.get('/manage/teams', async function (req, res, next) {
|
||||
const data = await teams.retrieve();
|
||||
|
||||
for(const team of data) {
|
||||
team.sport = await sports.getFromID(team.sportID);
|
||||
}
|
||||
|
||||
res.json(data);
|
||||
});
|
||||
|
||||
module.exports = router;
|
Reference in New Issue