fix(BoxPlayer): use a fallback for projected_points#656
fix(BoxPlayer): use a fallback for projected_points#656spkane31 wants to merge 6 commits intocwendt94:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #656 +/- ##
==========================================
- Coverage 71.21% 71.11% -0.11%
==========================================
Files 62 62
Lines 2376 2385 +9
==========================================
+ Hits 1692 1696 +4
- Misses 684 689 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cwendt94
left a comment
There was a problem hiding this comment.
Overall looks good, just some small suggestions!
espn_api/football/box_player.py
Outdated
| player_pool_entry = data.get('playerPoolEntry', {}) | ||
| player_stats = player_pool_entry.get('stats', []) | ||
| if len(player_stats) > 1: | ||
| projected_stat = player_stats[1] |
There was a problem hiding this comment.
I wonder if it is always going to be in the second position. A possible update could be to loop through player stats and look for statSourceId is equal to 0 which is projected points and then set. Also from your research was the stats only for the current year sometimes they have the previous year stats as well which would require a check for year as well against field seasonId
espn_api/football/box_player.py
Outdated
|
|
||
| # Backup projected_points extraction from raw data if not available from stats | ||
| if self.projected_points == 0: | ||
| try: |
There was a problem hiding this comment.
I think with how the code is setup it won't every throw using get and len checks
espn_api/football/box_player.py
Outdated
| if len(player_stats) > 1: | ||
| projected_stat = player_stats[1] | ||
| backup_projected = projected_stat.get('appliedTotal', 0) | ||
| if backup_projected > 0: |
There was a problem hiding this comment.
I don't think this check is necessary, can just simplfy by assigning self.projected_points = projected_stat.get('appliedTotal', 0) because its already zero it doesn't hurt.
|
Apologies for taking so long to respond, forgot about this PR. @cwendt94 thanks for the comments |
I dug through the JSON results for espn api pulls and found out the projected points is provided for previous years but it's hidden in a second list entry. I added a fallback way to find the projected points for a backup player. I tested this locally without issues.
Let me know your thoughts.