Speed up loading divisions on manage page
parent
42ac77ec6f
commit
18628e3fe5
|
@ -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() {
|
||||
|
|
|
@ -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;
|
Reference in New Issue