fix: limit number of surveys in environment state (#5715)

This commit is contained in:
Matti Nannt
2025-05-09 18:10:01 +02:00
committed by GitHub
parent 35b2356a31
commit 6be46b16b2
2 changed files with 8 additions and 0 deletions

View File

@@ -102,6 +102,8 @@ describe("getSurveysForEnvironmentState", () => {
expect(prisma.survey.findMany).toHaveBeenCalledWith({
where: { environmentId },
select: expect.any(Object), // Check if select is called, specific fields are in the original code
orderBy: { createdAt: "desc" },
take: 30,
});
expect(transformPrismaSurvey).toHaveBeenCalledWith(mockPrismaSurvey);
expect(result).toEqual([mockTransformedSurvey]);
@@ -116,6 +118,8 @@ describe("getSurveysForEnvironmentState", () => {
expect(prisma.survey.findMany).toHaveBeenCalledWith({
where: { environmentId },
select: expect.any(Object),
orderBy: { createdAt: "desc" },
take: 30,
});
expect(transformPrismaSurvey).not.toHaveBeenCalled();
expect(result).toEqual([]);

View File

@@ -21,6 +21,10 @@ export const getSurveysForEnvironmentState = reactCache(
where: {
environmentId,
},
orderBy: {
createdAt: "desc",
},
take: 30,
select: {
id: true,
welcomeCard: true,