fix: lineup data normalization + tomorrow match sync + player field mapping
This commit is contained in:
@@ -586,7 +586,40 @@ export class MatchesService {
|
||||
date: new Date(Number(liveMatch.mstUtc)),
|
||||
// Fill missing relations with empty arrays
|
||||
teamStats: [],
|
||||
playerParticipations: [],
|
||||
playerParticipations: (() => {
|
||||
const parsed: Array<{ teamId: string; isStarting: boolean; shirtNumber: string | number | null; position: string | null; player: { id: string; name: string } }> = [];
|
||||
if (liveMatch.lineups && typeof liveMatch.lineups === 'object') {
|
||||
const lu = liveMatch.lineups as Record<string, any>;
|
||||
const addPlayers = (teamLu: any, teamId: string | null) => {
|
||||
if (!teamLu || !teamId) return;
|
||||
if (teamLu.xi && Array.isArray(teamLu.xi)) {
|
||||
teamLu.xi.forEach((p: any) => {
|
||||
parsed.push({
|
||||
teamId,
|
||||
isStarting: true,
|
||||
shirtNumber: p.shirtNumber || p.number,
|
||||
position: p.position || p.pos,
|
||||
player: { id: p.personId || p.id || p.playerId || 'unknown', name: p.matchName || p.name || p.playerName || 'Bilinmiyor' }
|
||||
});
|
||||
});
|
||||
}
|
||||
if (teamLu.subs && Array.isArray(teamLu.subs)) {
|
||||
teamLu.subs.forEach((p: any) => {
|
||||
parsed.push({
|
||||
teamId,
|
||||
isStarting: false,
|
||||
shirtNumber: p.shirtNumber || p.number,
|
||||
position: p.position || p.pos,
|
||||
player: { id: p.personId || p.id || p.playerId || 'unknown', name: p.matchName || p.name || p.playerName || 'Bilinmiyor' }
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
addPlayers(lu.home, liveMatch.homeTeamId);
|
||||
addPlayers(lu.away, liveMatch.awayTeamId);
|
||||
}
|
||||
return parsed;
|
||||
})(),
|
||||
playerEvents: [],
|
||||
oddCategories: [], // Will handle odds parsing below
|
||||
officials: [],
|
||||
|
||||
Reference in New Issue
Block a user