mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-13 06:21:21 -05:00
29 lines
778 B
TypeScript
29 lines
778 B
TypeScript
import { Prisma } from "@prisma/client";
|
|
import prisma from "prisma/client";
|
|
|
|
export type GetAllSalmonRunRecordsData = Prisma.PromiseReturnType<
|
|
typeof getAllSalmonRunRecords
|
|
>;
|
|
|
|
export const getAllSalmonRunRecords = async (
|
|
userId?: number,
|
|
fetchUnapproved?: boolean
|
|
) =>
|
|
fetchUnapproved
|
|
? prisma.salmonRunRecord.findMany({
|
|
where: { approved: false },
|
|
include: {
|
|
rotation: true,
|
|
roster: true,
|
|
},
|
|
orderBy: { createdAt: "desc" },
|
|
})
|
|
: prisma.salmonRunRecord.findMany({
|
|
where: { OR: [{ approved: true }, { submitterId: userId ?? -1 }] },
|
|
include: {
|
|
rotation: true,
|
|
roster: true,
|
|
},
|
|
orderBy: [{ goldenEggCount: "desc" }, { createdAt: "desc" }],
|
|
});
|