Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Manager Page not loading #309

Open
Jhl44 opened this issue Jul 1, 2024 · 6 comments
Open

[BUG] Manager Page not loading #309

Jhl44 opened this issue Jul 1, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Jhl44
Copy link

Jhl44 commented Jul 1, 2024

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

@Jhl44 Jhl44 added the bug Something isn't working label Jul 1, 2024
@rc-davis3
Copy link

I can't get the managers page to load at all, just get 404 error.

@taylordeal4
Copy link

I also cannot get the manager page to load.

@Meister7K
Copy link

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.

@taylordeal4
Copy link

This worked. Thank you!

@Meister7K
Copy link

Meister7K commented Jul 28, 2024

#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,
         });
       }
     }
   }
 }; ```

boprice added a commit to boprice/league-page that referenced this issue Jul 31, 2024
@martyncisneros
Copy link

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?

Screenshot 2024-09-22 at 10 33 26 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants