[BUG] Manager Page not loading
Describe the bug Whenever I try to open manager page the website freezes, have to reload to unfreeze, but managers do not pop up.
Your League ID 1053852882170241024
I can't get the managers page to load at all, just get 404 error.
I also cannot get the manager page to load.
The issue is in the ManagerAwards.svelte file. Unsure of the exact issue but if you comment out the $: computePodiums(rosterID); the page will no longer throw the error (you won't get your awards section tho...). My current guess is that the issue has something to do with the 'cRosterID' variable.
This worked. Thank you!
#302 (same issue) So the Error is actually caused by a discrepancy in the length of the for loop that looks through the records. for some reason, some variables are shorter than the records.regularSeasonData.leagueWeekHighs.length. Here is the revised computePodiums variable for a quick fix. There may be a more permanent fix with within the allTimeRecords file that i plan to look through next. My theory is that this issue may only be affecting < 10 man leagues or leagues with only one year of data.
const computePodiums = (cRosterID) => {
formerGlobal = false;
displayAwards = [];
// first look through annual awards (champion, second, etc)
for (const podium of awards) {
for (const award in podium) {
if (award == "year") continue;
if (award == "divisions") {
for (const division of podium[award]) {
if (checkIfDeserves(division.rosterID, rosterID, podium.year)) {
const former = tookOver && tookOver > podium.year;
if (former) {
formerGlobal = true;
}
let awardTitle = "Regular Season Champion";
if (division.name) {
awardTitle = `${division.name} Division Champion`;
}
displayAwards.push({
award: awardTitle,
icon: "/awards/division.png",
type: "award",
originalName: getTeamNameFromTeamManagers(
leagueTeamManagers,
cRosterID,
podium.year
),
year: podium.year,
former,
});
}
}
} else if (checkIfDeserves(podium[award], cRosterID, podium.year)) {
const former = tookOver && tookOver > podium.year;
if (former) {
formerGlobal = true;
}
displayAwards.push({
award: capitalizeFirstLetter(award),
icon: "/awards/" + award + ".png",
type: "award",
originalName: getTeamNameFromTeamManagers(
leagueTeamManagers,
cRosterID,
podium.year
),
year: podium.year,
former,
});
}
}
}
//! Next look through record books
const leagueManagerRecords = [];
for (const key in records.regularSeasonData.leagueManagerRecords) {
const record = records.regularSeasonData.leagueManagerRecords[key];
record.rosterID = key;
leagueManagerRecords.push(record);
}
console.log(records.regularSeasonData)
const winRecords = [...leagueManagerRecords].sort(
(a, b) => b.wins - a.wins
);
const pointsRecords = [...leagueManagerRecords].sort(
(a, b) => b.fptsFor - a.fptsFor
);
const iqRecords = [...leagueManagerRecords].sort(
(a, b) => b.fptsFor / b.potentialPoints - a.fptsFor / a.potentialPoints
);
// First loop for the shorter arrays (winRecords, pointsRecords, iqRecords, mostSeasonLongPoints)
for (let i = 0; i < records.regularSeasonData.mostSeasonLongPoints.length; i++) {
const seasonLongRecord =
records.regularSeasonData.mostSeasonLongPoints[i];
const winRecord = winRecords[i];
const pointsRecord = pointsRecords[i];
const iqRecord = iqRecords[i];
if (
checkIfDeservesWithManagerID(winRecord?.rosterID, cRosterID) &&
i < 3
) {
displayAwards.push({
award: i + 1,
icon: "/awards/record-" + (i + 1) + ".png",
type: "All-Time Wins Record",
extraInfo: winRecord.wins,
wins: true,
});
}
if (
checkIfDeservesWithManagerID(pointsRecord?.rosterID, cRosterID) &&
i < 3
) {
displayAwards.push({
award: i + 1,
icon: "/awards/record-" + (i + 1) + ".png",
type: "All-Time Fantasy Points Record",
extraInfo: round(pointsRecord.fptsFor),
});
}
if (
checkIfDeservesWithManagerID(iqRecord?.rosterID, cRosterID) &&
i < 3
) {
displayAwards.push({
award: i + 1,
icon: "/awards/record-" + (i + 1) + ".png",
type: "All-Time Lineup IQ Record",
extraInfo: round((iqRecord.fptsFor * 100) / iqRecord.potentialPoints),
iq: true,
});
}
if (
checkIfDeserves(
seasonLongRecord.rosterID,
cRosterID,
seasonLongRecord.year
)
) {
const former = tookOver && tookOver > seasonLongRecord.year;
if (former) {
formerGlobal = true;
}
displayAwards.push({
award: i + 1,
icon: "/awards/" + (i < 3 ? `record-${i + 1}` : "generic") + ".png",
type: "All-Time Season Long Points",
originalName: getTeamNameFromTeamManagers(
leagueTeamManagers,
cRosterID,
seasonLongRecord.year
),
year: seasonLongRecord.year,
extraInfo: seasonLongRecord.fpts,
former,
});
}
}
// Second loop for the longer array (leagueWeekHighs)
for (let i = 0; i < records.regularSeasonData.leagueWeekHighs.length; i++) {
const leagueWeekRecord = records.regularSeasonData.leagueWeekHighs[i];
if (
checkIfDeserves(
leagueWeekRecord.rosterID,
cRosterID,
leagueWeekRecord.year
)
) {
const former = tookOver && tookOver > leagueWeekRecord.year;
if (former) {
formerGlobal = true;
}
displayAwards.push({
award: i + 1,
icon: "/awards/" + (i < 3 ? `record-${i + 1}` : "generic") + ".png",
type: "All-Time Single Week Record",
originalName: getTeamNameFromTeamManagers(
leagueTeamManagers,
cRosterID,
leagueWeekRecord.year
),
year: leagueWeekRecord.year,
week: leagueWeekRecord.week,
extraInfo: leagueWeekRecord.fpts,
former,
});
}
}
for (const yearRecords of records.regularSeasonData.seasonWeekRecords) {
for (let i = 0; i < 3; i++) {
const seasonPointsRecord = yearRecords.seasonPointsHighs[i];
if (
checkIfDeserves(
seasonPointsRecord.rosterID,
cRosterID,
yearRecords.year
)
) {
const former = tookOver && tookOver > yearRecords.year;
if (former) {
formerGlobal = true;
}
displayAwards.push({
award: i + 1,
icon: "/awards/" + (i < 3 ? `record-${i + 1}` : "generic") + ".png",
type: `${yearRecords.year} Single Week Record`,
originalName: getTeamNameFromTeamManagers(
leagueTeamManagers,
cRosterID,
seasonPointsRecord.year
),
year: null,
week: seasonPointsRecord.week,
extraInfo: seasonPointsRecord.fpts,
former,
});
}
}
}
}; ```
thanks @Meister7K. i tried making the changes you listed out (I matched my ManagerAwards.svelte file exactly to yours) but i'm still seeing the 404 page. wondering if you've had a chance to think through a more permanent fix?