-
Notifications
You must be signed in to change notification settings - Fork 206
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
Baseball: add getting box scores for categories #211
Conversation
espn_api/baseball/box_score.py
Outdated
|
||
home_team = self._process_team(data['home']) | ||
|
||
self.home_team = home_team['id'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For box score, you should add home and away team scores for the matchup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have home_wins
, home_losses
, and home_ties
, and away_wins
, away_losses
, and away_ties
defined below - or did you mean something else by the team scores?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wins and losses are for the teams overall record but box_score is getting information about a specific matchup against two teams. The home and away team scores shows the score between the two teams for the matchup.
For example this is the matchup/box_score for a league I am in: https://fantasy.espn.com/baseball/boxscore?leagueId=81134470&matchupPeriodId=6&scoringPeriodId=46&seasonId=2021&teamId=6&view=matchup. In this case the scores would be 433 and 295.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. So the league I've been looking at (my own) is a categories head to head league - so the wins and losses are for the matchup only, and not for the season. For example, in my case there are 12 categories, so the home score could be 6-5-1 (6 wins, 5 losses, 1 tie) and the away score would be 5-6-1.
I don't play in any points head to head leagues so I don't know how the data is represented in that case. How do you suggest we represent the different kinds of leagues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we use what's in the league settings (for me it's ['settings']['scoringSettings']['scoringType'] == 'H2H_CATEGORY'
and have different BoxScore
subclasses based on the league type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that makes a lot of sense with the wins/losses/ties information in the box score.
Yeah thats a great idea to use the league scoring setting. I have this same issue with basketball league as well for categories head to head scoring. I think making some generic sub box_score classes that all sports can use would be great and then can be set when the league is initialized.
I will create a ticket for this work, but in that case I think this PR is good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a stab at making the baseball BoxScore
a base class and having the baseball league set the boxscore subclass on instantiation - probably is portable for other sports (but I'm not currently in any ESPN leagues for other sports so I can't test a more general solution).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks this is a great start and I can definitely work on expanding this to other sports! I appreciate all of your work!
Codecov Report
@@ Coverage Diff @@
## master #211 +/- ##
==========================================
- Coverage 73.96% 73.48% -0.49%
==========================================
Files 45 46 +1
Lines 1552 1629 +77
==========================================
+ Hits 1148 1197 +49
- Misses 404 432 +28
Continue to review full report at Codecov.
|
I added retrieving box scores for baseball leagues that are head to head categories.
I also cleaned up some of the stat mappings (names and also the comments about them). I used the stats abbreviations from the glossary at the bottom of ESPN stat pages (see https://www.espn.com/mlb/player/stats/_/id/28976/max-scherzer for example).
The only semantic change is for stat
53
which was marked asQS
(quality starts) but I am certain isW
(wins), based on examining the box scores from my own league. I removed63
which was previouslyW
.