Description
Due to the 2-part season (Clausura and Apertura) nature of Liga MX, we're having trouble showing a table with the more recent part of their season.
Currently, it looks like our API successfully returns teams with the stageId attribute, however only half (9/18) of the teams are returned with the most recent stageId and relevant season data:

In this screenshot, in the front end code, I've hardcoded to filter the team data returned from our api and only show teams with a stageId = 13081116 (since that is the most recent half-season in MX).
The other half of teams currently returned have a stageId = 13081051
Suspected Cause
My best guess is that when our API creates the list of Liga MX teams from the Football API, we don't receive all of the teams in order of the stageId. I think that half of the teams are created with data from the previous half of the MX season and when the new version of that team (with the more recent stageId) is pulled from the Football API, we do not overwrite the previous version of that team.
This would lead to not all teams being created with the most recent half-season data.
Possible Solution
If a team were already created by our API and the Football API returns another team object/data with the same team id, we could check that new data's stageId and if it's greater in value than the current team, we destroy that team and replace it with the new team data.
That way, we have an automated way to keep season's up to date as they change. This is, of course, a guess because I'm not 100% sure how Football API works.
If stageId is something that's always increasing from season to season (which would make sense to me since seasons are chronological and not randomized), then this could be a future-proof solution.
Description
Due to the 2-part season (Clausura and Apertura) nature of Liga MX, we're having trouble showing a table with the more recent part of their season.
Currently, it looks like our API successfully returns teams with the

stageIdattribute, however only half (9/18) of the teams are returned with the most recentstageIdand relevant season data:In this screenshot, in the front end code, I've hardcoded to filter the team data returned from our api and only show teams with a
stageId=13081116(since that is the most recent half-season in MX).The other half of teams currently returned have a
stageId=13081051Suspected Cause
My best guess is that when our API creates the list of Liga MX teams from the Football API, we don't receive all of the teams in order of the stageId. I think that half of the teams are created with data from the previous half of the MX season and when the new version of that team (with the more recent
stageId) is pulled from the Football API, we do not overwrite the previous version of that team.This would lead to not all teams being created with the most recent half-season data.
Possible Solution
If a team were already created by our API and the Football API returns another team object/data with the same team id, we could check that new data's
stageIdand if it's greater in value than the current team, we destroy that team and replace it with the new team data.That way, we have an automated way to keep season's up to date as they change. This is, of course, a guess because I'm not 100% sure how Football API works.
If
stageIdis something that's always increasing from season to season (which would make sense to me since seasons are chronological and not randomized), then this could be a future-proof solution.