sendou.ink/prisma/queries/getLadderDay.ts
2021-02-04 20:37:22 +02:00

45 lines
1.1 KiB
TypeScript

import { Prisma } from "@prisma/client";
import prisma from "prisma/client";
export type GetLadderDayData = Prisma.PromiseReturnType<typeof getLadderDay>;
export const getLadderDay = async () => {
const d = new Date();
d.setHours(d.getHours() - 6);
return prisma.ladderDay.findFirst({
where: { date: { gte: d } },
include: {
matches: {
select: {
order: true,
maplist: true,
teamAScore: true,
teamBScore: true,
players: {
select: {
team: true,
user: {
select: {
id: true,
discordAvatar: true,
discordId: true,
discriminator: true,
username: true,
team: {
select: {
name: true,
nameForUrl: true,
twitterName: true,
},
},
},
},
},
},
},
},
},
});
};