joeyagreco / leeger

Instant stats for any fantasy football league.
https://pypi.org/project/leeger
MIT License
61 stars 17 forks source link

Sleeper playoff fixes/improvements. #24

Closed ssnider21 closed 2 years ago

ssnider21 commented 2 years ago

add support for sleeper for the 3 types of playoff round formats, and fix bug on incorrect labeling of first week of playoffs as regular season.

This will currently break the validation for checkOnlyOneChampionshipWeekInYear in the cases of both 2 week championship and 2 weeks per every round. I wasn't really able to determine the purpose of this check, so if I could, I'd like to remove that as well since passing validate=False will skip all validation.

This also creates a python 3.10 dependency since it uses match case. I can rework those parts if you don't want to introduce that.

joeyagreco commented 2 years ago

Hey Sean!

Thanks for looking into this!

Appreciate the time and effort this took.

Few things:

  1. Great catch with counting the first playoff week as a regular season week! That's obviously a pretty big bug when you're dealing with stat calculations.

  2. The check that ensures there is only 1 Championship week in a year is in place simply because the stat calculations do not currently support multi-week championship games. I realized when making this that it would eventually need to be supported but have not yet implemented it. It could indeed be implemented, but I did not have a league to test it on to ensure it was working properly. I can/will add this to the stat calculations in the very near future (likely with this change).

  3. As for implementing the switch statement, this should not be an issue as the library currently only supports Python 3.10+ (some things already that I'm using for dataclasses are only in 3.10).

  4. Could you explain a bit what the playoff_round_type's are and where you know that from? I didn't see that documented in Sleeper's API documentation when I was writing the Sleeper Wrapper

  5. For the sake of debugging (and since the Sleeper API is read only) do you mind sending your league info that you are using to test this? (league ID and years)

ssnider21 commented 2 years ago

playoff_round_type is just pulled from the league settings your sleeper library fetches. I just created a dummy league to test some settings, and [0, 1, 2] correspond in order to the options in the attached image.

Here are 2 league id's with slightly different settings you can use to debug: 854402777273720832 and 863904047973978112. Both only have history from 2021 unfortunately, I don't have any older sleeper leagues.

Screen Shot 2022-09-07 at 9 14 54 AM
joeyagreco commented 2 years ago

That makes sense.

I'm gunna add enums to the Sleeper library to make it more clear what the field represents and then add support to this library.

Before the library starts accepting multi-week playoff/championship matches, I'll have to support them in the stat calculations.

Supporting multi-week matchups is next on my todo list, so this should be coming soon.

ssnider21 commented 2 years ago

Sounds good. And just wanna say this is an incredible project overall. Used a variety of fantasy api wrappers and stat libraries in the past, and this is just simply way better.

joeyagreco commented 2 years ago

Sounds good. And just wanna say this is an incredible project overall. Used a variety of fantasy api wrappers and stat libraries in the past, and this is just simply way better.

Thank you! The goal I had for this was to make it the 1-stop-shop for getting stats for any fantasy league. Still a lot of ways to improve and expand but I plan on working on this for the foreseeable future.

joeyagreco commented 2 years ago

@ssnider21

I put a modified version of these changes in this pull request.

Could you please review it?