-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[ENHANCEMENT] Add Playoffs to Records Tab + Option to Filter Records by Regular Season, Playoffs, or Both #80
Comments
This is a very good idea. I'm inclined to only include playoffs as well. This will be open for at least a month though, so if anyone wants loser bracket rankings as well leave a comment and I'll add a toggle in the code to include or exclude them. |
P.S. I'm a huge fan of Svelte as a JavaScript framework. So hopefully you enjoy messing around with the code in this project! I use it for all my personal projects and I find it performs way better than react and is significantly easier to write than react or other frameworks. |
This request was echoed in issue #88 |
I got around to working on the logic for adding playoff stats. This is working for me, so I figured I'd pass it along. The first file is the full leagueRecords.js (from helperfunctions) and the second file is just the new playoff bits plus an example of something else I've been working on (more on that below). The basic structure is obviously just duplicating what you did for the regular season stats. I'm sure there are ways you could chop this down to not require so much duplication, but I'm still learning. The logic works thanks to the fact that Sleeper assigns matchup_ids during the playoff weeks to the playoff bracket first. So like, for your standard 6-team, 1 week/round playoffs, the last week of the playoffs the championship match has matchupID 1, and the "bronze medal" match has matchupID 2. So for every combination of playoff type and number of playoff teams, I determined A) how long the playoffs would last and B) how many matchups need to be grabbed in each week. There are four different possible groups of matchupIDs that one would need:
And you can see that's why the real "meat" of the code is, more or less, duplicated 4x, but only returned if it's what you want given the week and the league's playoff settings. Here is a screengrab showing some notes about which outputs are required from which "playoffcases": All of this takes into account the fact that before 2019, only standard 1 week/round was possible, and then in 2020, 2 weeks/round was added as an option, and then this year 1 w/r but 2-week championship. At least that's how it happened as far as I'm aware. IN OTHER NEWS: You'll see that I'm indexing everything by "recordManID" instead of "rosterID". (To get the playoff stuff working for you, I'm pretty sure you can just replace all instances of the former with the latter). In the second file below, I included some more snippets of code related to this indexing scheme to help explain what I'm doing. Basically I wanted every manager to have their own records history, rather than having everything tied to rosterIDs. So the 2 guys who joined us this year have stats separate from the guys who previously owned the rosters they took over. I've gotten this working for the Records tab, but I'm still working on getting everything squared away for the Managers and Awards tabs. I believe with the way I've done this, it shouldn't be difficult to make it togglable in the code which way you want to track the records (although I haven't done this yet). Below is a link to my testing repository and associated vercel page, so you can see everything I'm doing and let me know what you think. I've formatted the actual data in the tables how I want it to appear, but the size/placement of the tables is something I still have yet to work on. Other things I've added are:
Some things on my to-do list now that I have the player records pretty much set up:
https://github.com/OldNewsBlues/america-first-main Playoff Stats (leagueRecords js).txt Edit: fixed small, non-bug-producing error |
I now have Playoff records + filtering fully functional. Code and example can be seen here: https://github.com/OldNewsBlues/america-first-main |
This is great. I like a lot of the things you've implemented in your page. I've started meeting your PRs and will try to get this stuff implemented asap. Thanks for all the hard work! Also, feel free to update your contribution info in the package.json if you want. I wasn't sure if I should use your 2 account that created the PRs or your primary one instead. |
Currently the Records tab only tracks regular season fantasy stats.
It'd be nice to add fantasy playoffs stats to the Records tab, along with an option (on the actual page) to filter the tables/graphs for RS, PO, or both.
Regarding playoffs stats, I'd personally want this limited to only the games in the actual playoff bracket (i.e. excluding the "toilet bowl" games in the losers bracket). For various reasons - most commonly, the managers in the losers bracket just not caring to set their line-ups - stats from those games wouldn't be proper to include for record-keeping purposes. But I realize other leagues may not have such issues and therefore may prefer to have those games included. For that reason, if they were to be included by default, it'd be nice to have a variable in the code we can adjust to exclude them.
League ID: 725417455366799360
Thanks for all the amazing work you've done on this! Seriously, this is such a high-quality resource, and I'm enjoying sharpening my own coding knowledge by tinkering with my league-page's code.
The text was updated successfully, but these errors were encountered: