Speed up loading divisions on manage page
parent
42ac77ec6f
commit
18628e3fe5
|
@ -115,7 +115,7 @@ CATEGORIES.push(new Category(
|
||||||
CATEGORIES.push(new Category(
|
CATEGORIES.push(new Category(
|
||||||
"divisions",
|
"divisions",
|
||||||
async function getDivisions() {
|
async function getDivisions() {
|
||||||
return await Data.getDivisions();
|
return await (await fetch('/fetch/manage/divisions')).json();
|
||||||
},
|
},
|
||||||
async function listDivisionHeaders() {
|
async function listDivisionHeaders() {
|
||||||
const headerRow = document.createElement('tr');
|
const headerRow = document.createElement('tr');
|
||||||
|
@ -151,8 +151,8 @@ CATEGORIES.push(new Category(
|
||||||
row.appendChild(spacerCell);
|
row.appendChild(spacerCell);
|
||||||
|
|
||||||
const sportCell = document.createElement('td');
|
const sportCell = document.createElement('td');
|
||||||
Data.getSportName(division.sportID)
|
let sportName = division.sport.name;
|
||||||
.then(data => sportCell.textContent = data);
|
sportCell.textContent = sportName;
|
||||||
row.appendChild(sportCell);
|
row.appendChild(sportCell);
|
||||||
},
|
},
|
||||||
async function addDivision() {
|
async function addDivision() {
|
||||||
|
|
|
@ -126,4 +126,14 @@ router.get('/submit', async function(req, res, next) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get('/manage/divisions', async function (req, res, next) {
|
||||||
|
const data = await divisions.retrieve();
|
||||||
|
|
||||||
|
for(const division of data) {
|
||||||
|
division.sport = await sports.getFromID(division.sportID);
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json(data);
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
Reference in New Issue