Skip to content

fix(BoxPlayer): use a fallback for projected_points#656

Open
spkane31 wants to merge 6 commits intocwendt94:masterfrom
spkane31:spk/projection-previous-seasons
Open

fix(BoxPlayer): use a fallback for projected_points#656
spkane31 wants to merge 6 commits intocwendt94:masterfrom
spkane31:spk/projection-previous-seasons

Conversation

@spkane31
Copy link
Contributor

@spkane31 spkane31 commented Aug 23, 2025

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.

@codecov
Copy link

codecov bot commented Aug 23, 2025

Codecov Report

❌ Patch coverage is 87.80488% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.11%. Comparing base (98f570e) to head (3346736).

Files with missing lines Patch % Lines
espn_api/football/box_player.py 87.80% 5 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Owner

@cwendt94 cwendt94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just some small suggestions!

player_pool_entry = data.get('playerPoolEntry', {})
player_stats = player_pool_entry.get('stats', [])
if len(player_stats) > 1:
projected_stat = player_stats[1]
Copy link
Owner

@cwendt94 cwendt94 Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


# Backup projected_points extraction from raw data if not available from stats
if self.projected_points == 0:
try:
Copy link
Owner

@cwendt94 cwendt94 Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with how the code is setup it won't every throw using get and len checks

if len(player_stats) > 1:
projected_stat = player_stats[1]
backup_projected = projected_stat.get('appliedTotal', 0)
if backup_projected > 0:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@spkane31 spkane31 requested a review from cwendt94 December 15, 2025 23:46
@spkane31
Copy link
Contributor Author

Apologies for taking so long to respond, forgot about this PR. @cwendt94 thanks for the comments

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.

2 participants