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