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

Baseball: add getting box scores for categories #211

Merged
merged 3 commits into from
May 18, 2021

Conversation

cdchan
Copy link
Contributor

@cdchan cdchan commented May 16, 2021

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 as QS (quality starts) but I am certain is W (wins), based on examining the box scores from my own league. I removed 63 which was previously W.


home_team = self._process_team(data['home'])

self.home_team = home_team['id']
Copy link
Owner

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.

Copy link
Contributor Author

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?

Copy link
Owner

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.

Copy link
Contributor Author

@cdchan cdchan May 17, 2021

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?

Copy link
Contributor Author

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.

Copy link
Owner

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!

Copy link
Contributor Author

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).

Copy link
Owner

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-commenter
Copy link

codecov-commenter commented May 17, 2021

Codecov Report

Merging #211 (551b20f) into master (d723118) will decrease coverage by 0.48%.
The diff coverage is 55.35%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
espn_api/baseball/constant.py 100.00% <ø> (ø)
espn_api/baseball/box_score.py 52.08% <52.08%> (ø)
espn_api/baseball/league.py 65.17% <75.00%> (+6.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d723118...551b20f. Read the comment docs.

@cwendt94 cwendt94 merged commit b935647 into cwendt94:master May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants