This commit is contained in:
2026-04-23 22:22:59 +03:00
parent df428ed1e8
commit 634204acf0
6 changed files with 2064 additions and 90 deletions
+33 -14
View File
@@ -99,21 +99,40 @@ export class LeaguesService {
}
/**
* Get team's matches (past + upcoming)
* Get team's matches (past + upcoming) with pagination
*/
async getTeamRecentMatches(teamId: string, limit: number = 50) {
return this.prisma.match.findMany({
where: {
OR: [{ homeTeamId: teamId }, { awayTeamId: teamId }],
},
include: {
homeTeam: true,
awayTeam: true,
league: { include: { country: true } },
},
orderBy: { mstUtc: "desc" },
take: limit,
});
async getTeamRecentMatches(
teamId: string,
page: number = 1,
limit: number = 20,
) {
const skip = (page - 1) * limit;
const where = {
OR: [{ homeTeamId: teamId }, { awayTeamId: teamId }],
};
const [data, total] = await this.prisma.$transaction([
this.prisma.match.findMany({
where,
include: {
homeTeam: true,
awayTeam: true,
league: { include: { country: true } },
},
orderBy: { mstUtc: "desc" },
skip,
take: limit,
}),
this.prisma.match.count({ where }),
]);
return {
data,
total,
page,
limit,
totalPages: Math.ceil(total / limit),
};
}
/**