This commit is contained in:
@@ -898,6 +898,58 @@ export class FeederPersistenceService {
|
||||
.map((m) => m.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* For a list of match IDs that ALREADY exist in DB,
|
||||
* returns which data scopes are missing per match.
|
||||
* Only checks completed (Ended) football/basketball matches.
|
||||
*/
|
||||
async getMissingScopes(
|
||||
matchIds: string[],
|
||||
): Promise<Map<string, string[]>> {
|
||||
const result = new Map<string, string[]>();
|
||||
if (matchIds.length === 0) return result;
|
||||
|
||||
const matches = await this.prisma.match.findMany({
|
||||
where: {
|
||||
id: { in: matchIds },
|
||||
state: "Ended",
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
sport: true,
|
||||
_count: {
|
||||
select: {
|
||||
playerParticipations: true,
|
||||
footballTeamStats: true,
|
||||
basketballTeamStats: true,
|
||||
basketballPlayerStats: true,
|
||||
oddCategories: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
for (const m of matches) {
|
||||
const missing: string[] = [];
|
||||
|
||||
if (m.sport === "football") {
|
||||
if (m._count.footballTeamStats === 0) missing.push("stats");
|
||||
if (m._count.playerParticipations < 18) missing.push("lineups");
|
||||
} else if (m.sport === "basketball") {
|
||||
if (m._count.basketballTeamStats === 0) missing.push("stats");
|
||||
if (m._count.basketballPlayerStats === 0) missing.push("lineups");
|
||||
}
|
||||
|
||||
if (m._count.oddCategories === 0) missing.push("odds");
|
||||
|
||||
if (missing.length > 0) {
|
||||
result.set(m.id, missing);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async hasOdds(matchId: string): Promise<boolean> {
|
||||
const category = await this.prisma.oddCategory.findFirst({
|
||||
where: { matchId },
|
||||
|
||||
Reference in New Issue
Block a user