Speed up loading divisions on manage page

main
sudoer777 2022-03-09 10:28:28 -07:00
parent 42ac77ec6f
commit 18628e3fe5
2 changed files with 13 additions and 3 deletions

View File

@ -115,7 +115,7 @@ CATEGORIES.push(new Category(
CATEGORIES.push(new Category(
"divisions",
async function getDivisions() {
return await Data.getDivisions();
return await (await fetch('/fetch/manage/divisions')).json();
},
async function listDivisionHeaders() {
const headerRow = document.createElement('tr');
@ -151,8 +151,8 @@ CATEGORIES.push(new Category(
row.appendChild(spacerCell);
const sportCell = document.createElement('td');
Data.getSportName(division.sportID)
.then(data => sportCell.textContent = data);
let sportName = division.sport.name;
sportCell.textContent = sportName;
row.appendChild(sportCell);
},
async function addDivision() {

View File

@ -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;