fix(baseball): correct player position and free_agents position filter - #687
Merged
Merged
Conversation
Player.position was using POSITION_MAP (lineupSlotId numbering) with a -1 offset to look up defaultPositionId, causing pitchers and position players to map to the wrong position (e.g. SP→C, RP→DH). Fix by introducing DEFAULT_POSITION_MAP which maps defaultPositionId directly to position strings — a separate numbering system from the lineup slot IDs in POSITION_MAP. Also completes the reverse str→int entries in POSITION_MAP (previously marked '# reverse TODO'), enabling free_agents(position=...) to correctly filter by lineup slot ID.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #687 +/- ##
==========================================
+ Coverage 71.06% 71.09% +0.02%
==========================================
Files 62 62
Lines 2426 2425 -1
==========================================
Hits 1724 1724
+ Misses 702 701 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Owner
|
Thanks for fixing this issue and adding unit tests! |
gdifiore
pushed a commit
to gdifiore/espn-api
that referenced
this pull request
Mar 26, 2026
…gents fix(baseball): correct player position and free_agents position filter
gdifiore
pushed a commit
to gdifiore/espn-api
that referenced
this pull request
Mar 26, 2026
…gents fix(baseball): correct player position and free_agents position filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Player.position used POSITION_MAP (lineup slot IDs) with a -1 offset to resolve defaultPositionId, causing wrong positions for nearly every player (e.g. Bryan Woo: C instead of SP). The two ID systems are unrelated — defaultPositionId=1 means SP, but lineup slot 0 is C.
Reproducible PoC: