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] Records - Single Week Scoring (both All-Time and every Year) - incorrect weeks displayed & problems after switching pages #77

Closed
OldNewsBlues opened this issue Sep 27, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@OldNewsBlues
Copy link
Contributor

OldNewsBlues commented Sep 27, 2021

Both bugs in the Records tab

  1. While the rankings and points are correct, they have the wrong Week listed with them. And it looks like the discrepancy is due to the week # being calculated in inverse order (from the last regular season game played). For example (with my league with years 2019-2021, 13 game regular season in 19/20 and 14 in 21):

2021 - Top "Week 1" scores actually happened in Week 2, and vice versa. (Obviously, we don't know how Week 3 scores will be reflected yet, but I suspect that top Week 3 scores will be displayed as "Week 1", vice versa w/ top Week 1 scores, and Week 2 scores will "correctly" be displayed as "Week 2" - but only because it's the middle week of 3 played weeks)

2020 - "Week 8" scores should be Week 6. "Week 2" scores should be Week 12. "Week 10" scores should be Week 4. "Week 7" scores ARE "correctly" displayed as Week 7 (but again, probably only because it's the middle week of 13 played weeks)

2019 - "Week 6" scores should be Week 8. "Week 9" scores should be Week 5. "Week 5" scores should be Week 9. "Week 13" should be Week 1.

And this occurs in both the All-Time and the 2021/2020/2019 tables (i.e. same top scores show the same incorrect weeks).

[[[POSSIBLE SOURCE OF BUG - but ignore if it doesn't help - I'm just a novice coder]]]: I'm assuming the problem has something to do with how you're assigning the "week" variable in src/lib/utils/helperFunctions/leagueRecords.js.

You start by assigning it to "nflState.week - 1" if NFL is in regular season and 18 if NFL is in the post season. And for "complete" leagues (i.e. past seasons), you assign it to "leagueData.settings.playoff_week_start - 1".

Then you fetch the Sleeper data in inverse week order - i.e. it starts at either "nflState.week - 1" or "leagueData.settings.playoff_week_start - 1" and works backward until week "0"

But then when you process the matchup data, you assign "matchupWeek" to 0 and have it work UPWARD to "matchupsData.length", with each cycle re-assigning "week" to "matchupWeek + 1". And this appears to be the week # that is ultimately displayed.


  1. This bug appears in the "Total Points" column in both the All-Time and Yearly top week scores tables. When the Records tab first loads, the points are shown correctly. Now switch to any different tab. Now switch back to the Records tab. The points are still shown correctly, but any totals ending in something like "150.3" now show "150.30". Now switch to any different tab again. Now switch back to the Records tab. All entries in the "Total Points" column now display "NaN". Now, switching tabs will not bring the scores back. Only refreshing will (which then repeats the above cycle).

[[[by the way, I'd prefer if the 2 decimal digits were always displayed - i.e. "150.3" is always "150.30"]]]


League ID: 725417455366799360
(but your demo/personal league page has the same bugs, or at least the one with switching pages)

Desktop:
macOS Catalina 10.15.7
Chrome Version 93.0.4577.63


By the way, I have a feature request for the Records tab: Could we get an option (on the page) to have these rankings display for "Regular Season", "Playoffs", or "Both", with the Playoffs reflecting only the playoff bracket games (i.e. not the losing bracket/toilet bowl games) (or at least the option in the CODE to exclude toilet bowl games)?

@OldNewsBlues OldNewsBlues added the bug Something isn't working label Sep 27, 2021
@nmelhado
Copy link
Owner

Thanks for the in-depth writeup! Completely missed this. I've solved the bug in pr #78.

Currently the records only display regular season records. The logic to include playoffs is much more complicated, but probably worth adding. Would you mind opening up a separate feature request ticket with that suggestion? I'm going to close this ticket because the bug is fixed now.

Thank you for the help!

@nmelhado
Copy link
Owner

Missed the second bug reported here

@nmelhado
Copy link
Owner

Second bug fixed in pr #79

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

2 participants