mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-04 10:30:00 -06:00
added service deleteResponseById
This commit is contained in:
@@ -58,8 +58,8 @@ export default function SummaryMetadata({ responses, survey }: SummaryMetadataPr
|
||||
/>
|
||||
<StatCard
|
||||
label="Drop Offs"
|
||||
percentage={`${Math.round(((totalResponses - completedResponses) / totalDisplays) * 100)}%`}
|
||||
value={responses.length === 0 ? <span>-</span> : totalResponses - completedResponses}
|
||||
percentage={`${Math.round(((totalDisplays - completedResponses) / totalDisplays) * 100)}%`}
|
||||
value={responses.length === 0 ? <span>-</span> : totalDisplays - completedResponses}
|
||||
tooltipText="People who started but did not complete the survey"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -17,6 +17,7 @@ import { captureTelemetry } from "../telemetry";
|
||||
import { validateInputs } from "../utils/validate";
|
||||
import { ZId } from "@formbricks/types/v1/environment";
|
||||
import { revalidateTag } from "next/cache";
|
||||
import { deleteDisplayByResponseId } from "../services/displays";
|
||||
|
||||
const responseSelection = {
|
||||
id: true,
|
||||
@@ -334,6 +335,7 @@ export const deleteResponse = async (responseId: string): Promise<TResponse> =>
|
||||
person: responsePrisma.person ? transformPrismaPerson(responsePrisma.person) : null,
|
||||
tags: responsePrisma.tags.map((tagPrisma: { tag: TTag }) => tagPrisma.tag),
|
||||
};
|
||||
deleteDisplayByResponseId(responseId);
|
||||
return response;
|
||||
} catch (error) {
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
|
||||
@@ -39,6 +39,14 @@ const selectDisplay = {
|
||||
},
|
||||
status: true,
|
||||
};
|
||||
export const getDisplayCount = async (surveyId) => {
|
||||
const numDisplays = await prisma.display.findMany({
|
||||
where: {
|
||||
surveyId,
|
||||
},
|
||||
});
|
||||
return numDisplays;
|
||||
};
|
||||
|
||||
export const updateDisplay = async (
|
||||
displayId: string,
|
||||
@@ -203,3 +211,22 @@ export const getDisplaysOfPerson = cache(
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export const deleteDisplayByResponseId = async (responseId: string): Promise<void> => {
|
||||
validateInputs([responseId, ZId]);
|
||||
try {
|
||||
await prisma.display.delete({
|
||||
where: {
|
||||
responseId,
|
||||
},
|
||||
});
|
||||
console.log("deleted");
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
throw new DatabaseError("Database operation failed");
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user