@@ -587,12 +587,19 @@ export class MatchesService {
|
||||
// Fill missing relations with empty arrays
|
||||
teamStats: [],
|
||||
playerParticipations: (() => {
|
||||
const parsed: Array<{ teamId: string; isStarting: boolean; shirtNumber: string | number | null; position: string | null; player: { id: string; name: string } }> = [];
|
||||
const canTrustFeedLineups = displayStatus === "LIVE" || displayStatus === "Finished";
|
||||
const parsed: Array<{
|
||||
teamId: string;
|
||||
isStarting: boolean;
|
||||
shirtNumber: string | number | null;
|
||||
position: string | null;
|
||||
player: { id: string; name: string };
|
||||
}> = [];
|
||||
const canTrustFeedLineups =
|
||||
displayStatus === "LIVE" || displayStatus === "Finished";
|
||||
if (!canTrustFeedLineups) {
|
||||
return parsed;
|
||||
}
|
||||
if (liveMatch.lineups && typeof liveMatch.lineups === 'object') {
|
||||
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;
|
||||
@@ -603,7 +610,11 @@ export class MatchesService {
|
||||
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' }
|
||||
player: {
|
||||
id: p.personId || p.id || p.playerId || "unknown",
|
||||
name:
|
||||
p.matchName || p.name || p.playerName || "Bilinmiyor",
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -614,7 +625,11 @@ export class MatchesService {
|
||||
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' }
|
||||
player: {
|
||||
id: p.personId || p.id || p.playerId || "unknown",
|
||||
name:
|
||||
p.matchName || p.name || p.playerName || "Bilinmiyor",
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -641,7 +656,8 @@ export class MatchesService {
|
||||
scoreHome: match.scoreHome,
|
||||
scoreAway: match.scoreAway,
|
||||
});
|
||||
const canTrustStoredLineups = this.canTrustStoredLineups(detailDisplayStatus);
|
||||
const canTrustStoredLineups =
|
||||
this.canTrustStoredLineups(detailDisplayStatus);
|
||||
|
||||
if (Array.isArray(match.playerParticipations)) {
|
||||
if (!canTrustStoredLineups) {
|
||||
@@ -865,9 +881,7 @@ export class MatchesService {
|
||||
|
||||
if (!rows.length) return [];
|
||||
|
||||
const latestMst = Math.max(
|
||||
...rows.map((row) => Number(row.mstUtc || 0)),
|
||||
);
|
||||
const latestMst = Math.max(...rows.map((row) => Number(row.mstUtc || 0)));
|
||||
const ageDays =
|
||||
latestMst > 0
|
||||
? (beforeDateMs - latestMst) / (24 * 60 * 60 * 1000)
|
||||
@@ -901,8 +915,7 @@ export class MatchesService {
|
||||
|
||||
const rank = matchOrder.get(String(row.matchId)) ?? matchLimit;
|
||||
const recencyWeight = Math.max(1, matchLimit - rank);
|
||||
const score =
|
||||
recencyWeight + (rank === 0 ? 3 : rank === 1 ? 1.5 : 0);
|
||||
const score = recencyWeight + (rank === 0 ? 3 : rank === 1 ? 1.5 : 0);
|
||||
const existing = playerMap.get(playerId);
|
||||
|
||||
if (!existing) {
|
||||
@@ -996,9 +1009,7 @@ export class MatchesService {
|
||||
private canTrustStoredLineups(displayStatus?: string): boolean {
|
||||
const normalized = String(displayStatus || "").toLowerCase();
|
||||
return (
|
||||
normalized === "live" ||
|
||||
normalized === "finished" ||
|
||||
normalized === "ft"
|
||||
normalized === "live" || normalized === "finished" || normalized === "ft"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user