cwendt94 / espn-api

ESPN Fantasy API! (Football, Basketball)
MIT License
544 stars 183 forks source link

feat: Add standings_weekly method Football League Class #513

Closed brthurr closed 6 months ago

brthurr commented 6 months ago

Method of the Football League class that will return a list of teams in the order of their standing for a current week. The method calculates the number of wins, losses, points for and points against from week 1 to the provided week. If no week is provided, it will calculate to the league.current_week.

Included test for the method as well.

brthurr commented 6 months ago

I have a question that may kill this PR.

Any way of knowing if ESPN calculates points for and points against in real-time? For example, If I run standings on a Sunday at 3PM, will it return PF and PA up to 3 PM, taking into account the noon games that have already been played? Or does it wait for a weekly final, and it only will return PF and PA for the previous full week.

I want to test but won't be able to do so until Thursday when they actually play a game.

DesiPilla commented 6 months ago

@brthurr

I have a question that may kill this PR.

Any way of knowing if ESPN calculates points for and points against in real-time? For example, If I run standings on a Sunday at 3PM, will it return PF and PA up to 3 PM, taking into account the noon games that have already been played? Or does it wait for a weekly final, and it only will return PF and PA for the previous full week.

I want to test but won't be able to do so until Thursday when they actually play a game.

It depends on how you mean points_for. The object team.scores is updated live. But the team.points_for object I'm pretty sure is not live (since the league standings displayed on the site doesn't update until the week is over).

Do you want it to be live? Or do you want something static?

brthurr commented 6 months ago

For my purposes, I want it to be static. I'm using it to determine standings at the end of the regular season (for our league, week 14) in order to populate my customer "losers bracket". I have code in my app that already determines if league.current_week is > 14. I was looking at this from the perspective of others who may want to use this method.

DesiPilla commented 6 months ago

@brthurr the tiebreaking process is quite complicated, but I took a stab at it here.

cwendt94 commented 6 months ago

@brthurr does @DesiPilla PR look to solve the weekly standings? If so we can close this one.

brthurr commented 6 months ago

@cwendt94, yep, this looks great! Thanks for the hard work, @DesiPilla! Closing PR.