perf: improve insights where query and type fix (#18211)

* perf: insights perf improvement

* removed additional const
This commit is contained in:
Alex van Andel authored and GitHub committed 2024-12-16 15:50:20 +00:00
1 parent 423b17a819
commit 04d7537e2f
2 files changed
+10 -12

No files matched your search

@@ -158,13 +158,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
take: 10,
});
const eventTypeIds = bookingsFromSelected
.filter((booking) => typeof booking.eventTypeId === "number")
.map((booking) => booking.eventTypeId);
const eventTypeIds = bookingsFromSelected.reduce((acc: number[], booking) => {
if (typeof booking.eventTypeId !== "number") return acc;
return [...acc, booking.eventTypeId];
}, []);
const eventTypeWhereConditional: Prisma.EventTypeWhereInput = {
id: {
in: eventTypeIds as number[],
in: eventTypeIds,
},
};