This commit is contained in:
@@ -856,19 +856,46 @@ export class FeederPersistenceService {
|
||||
const matches = await this.prisma.match.findMany({
|
||||
where: {
|
||||
id: { in: matchIds },
|
||||
AND: [
|
||||
{ oddCategories: { some: {} } },
|
||||
oddCategories: { some: {} },
|
||||
OR: [
|
||||
{
|
||||
OR: [
|
||||
{ footballTeamStats: { some: {} } },
|
||||
{ basketballTeamStats: { some: {} } },
|
||||
],
|
||||
sport: "football",
|
||||
footballTeamStats: { some: {} },
|
||||
playerParticipations: { some: { isStarting: true } },
|
||||
},
|
||||
{
|
||||
sport: "basketball",
|
||||
basketballTeamStats: { some: {} },
|
||||
basketballPlayerStats: { some: {} },
|
||||
},
|
||||
],
|
||||
},
|
||||
select: { id: true },
|
||||
select: { id: true, sport: true },
|
||||
});
|
||||
return matches.map((m) => m.id);
|
||||
|
||||
const footballIds = matches
|
||||
.filter((m) => m.sport === "football")
|
||||
.map((m) => m.id);
|
||||
const completeFootballIds = new Set<string>();
|
||||
|
||||
if (footballIds.length > 0) {
|
||||
const starterCounts = await this.prisma.matchPlayerParticipation.groupBy({
|
||||
by: ["matchId"],
|
||||
where: {
|
||||
matchId: { in: footballIds },
|
||||
isStarting: true,
|
||||
},
|
||||
_count: { _all: true },
|
||||
});
|
||||
|
||||
for (const row of starterCounts) {
|
||||
if (row._count._all >= 18) completeFootballIds.add(row.matchId);
|
||||
}
|
||||
}
|
||||
|
||||
return matches
|
||||
.filter((m) => m.sport !== "football" || completeFootballIds.has(m.id))
|
||||
.map((m) => m.id);
|
||||
}
|
||||
|
||||
async hasOdds(matchId: string): Promise<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user