Closed KCNilssen closed 1 year ago
@Mattsface What do you think, should we temporarily change the tests to "wait out" till the season starts to see if this is how the MLB api handles offseason stats requests for season or should we handle it with some code checking the date against the mlb season start and end dates when asking for season stats?
Not sure what we can really do besides just wait it out and see given the lack of public facing documentation on the api
@KCNilssen I will explore updating the pytests to add a specific season parameter. I believe you might be on to something with the new season starting.
@Mattsface I think the only thing to do at the moment is wait it out and see. I tried to find information on It and came up empty.
https://statsapi.mlb.com/api/v1/people/663728/stats?stats=season&season=2018&group=catching
Adding the season param for 2018 to see if that would change anything still results in an empty return. I think this issue must be with season stats? Issues could be:
@Mattsface I think the only thing to do at the moment is wait it out and see. I tried to find information on It and came up empty.
https://statsapi.mlb.com/api/v1/people/663728/stats?stats=season&season=2018&group=catching
Adding the season param for 2018 to see if that would change anything still results in an empty return. I think this issue must be with season stats? Issues could be:
- They are updating season stats and have chosen this for the mean time?
- Season stats are broken on api side
- They have completely changed the endpoint and the way we get stats
Let's give it a few days to see how things work out. I wish we had some information from the MLB on this.
PR Made. I added the season param to all stat tests.
Resolved with PR that includes a specified season for season stats to use to avoid the offseason mlb stats returning empty values.
Output:
Issues:
Team endpoint that should return hitting stats for season: https://statsapi.mlb.com/api/v1/teams/133/stats?stats=season,career&group=hitting
MLB api now returns Object not found when asked for season stats, which is a new output we have not seen before from the MLB api. When an addition stats type is included such as stats=season,career instead of just stats=season, we are returned a normal return but with only stats for career, it does not even include an empty season stats.
People endpoint that should return stats for season and seasonAdvanced: https://statsapi.mlb.com/api/v1/people/660271/stats?stats=season,seasonAdvanced&group=pitching
MLB api returns an empty stats object, which unlike above, an empty stats object that I assume is meant to contain the pitching season and seasonAdvanced stats objects. When an additional group is added like above, stats=season,seasonAdvanced,career, only the career pitching stats are returned, missing both the season and seasonAdvanced.
Summery: The failed tests are all tied with the season and seasonAdvanced stat types. Because of these issues when we ask for 4 stat types and two of which are the issued season types, only 2 stat types are returned. Meaning that with a test expecting 4 but only receiving two, it fails, creating an assertionError. Example below where we ask for season and career catching stats. Since only one is returned when we check, 1 != 2 and thus the AssertionError:
Thoughts
I think this may have something to do with it being the offseason. Could this be how the MLB api handles its returns for between seasons or is this the result of a change or update with the MLB api and how they handle these endpoints? Due the the lack of api information that is publicly available at this time we have no real idea.