Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

133 find the expert broken #136

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
npm ci
cp .env.example .env # an env file is needed for `build`
npm run db:generate
npm run db:deploy
npm run build
npm ci --prod
rm .env
Expand Down
48 changes: 11 additions & 37 deletions src/server/api/routers/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,6 @@ export const surveyRouter = createTRPCRouter({
return userAnswers;
}),

// setOptIn: protectedProcedure
// .input(z.object({ userId: z.string() }))
// .mutation(async ({ ctx, input }) => {
// const user = await ctx.db.user.findUnique({
// where: {
// id: input.userId,
// },
// });

// if (!user) {
// throw new TRPCClientError("User not found");
// }

// await ctx.db.user.update({
// where: {
// id: input.userId,
// },
// data: {
// findExpertOptIn: !user.findExpertOptIn,
// },
// });
// }),

setDefaultRole: protectedProcedure
.input(z.object({ userId: z.string(), roleIds: z.array(z.string()) }))
.mutation(async ({ ctx, input }) => {
Expand Down Expand Up @@ -324,25 +301,22 @@ export const surveyRouter = createTRPCRouter({
});

if (existingAnswer) {
// update the existing answer
await ctx.db.questionResult.update({
// delete the existing answer
await ctx.db.questionResult.delete({
where: {
id: existingAnswer.id,
},
data: {
answerId,
},
});
} else {
// create a new answer
await ctx.db.questionResult.create({
data: {
userId,
questionId,
answerId,
},
});
}

// create a new answer
await ctx.db.questionResult.create({
data: {
userId,
questionId,
answerId,
},
});
}),
);
} catch (error) {
Expand Down
4 changes: 1 addition & 3 deletions src/utils/data-manipulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ const pushUserData = (
userMap[entry.userId]!.communicationPreferences?.length > 0
? userMap[entry.userId]?.communicationPreferences
: ["Do not contact"],
answer:
(answerOptionMap[entry.answerId] as { answer?: string })?.answer ??
"Unknown Answer",
answer: answerOptionMap[entry.answerId] ?? "Unknown Answer",
});
};

Expand Down
Loading