Skip to content

Commit 06f95ba

Browse files
authored
hotfix: if question cannot be found via identifier, search via other … (#398)
…identifier
2 parents 8e33914 + abdb22c commit 06f95ba

File tree

1 file changed

+17
-1
lines changed
  • src/utils/data/questions

1 file changed

+17
-1
lines changed

src/utils/data/questions/get.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const getQuestion = async (
1818
}
1919

2020
try {
21-
const res = await prisma.questions.findUnique({
21+
let res = await prisma.questions.findUnique({
2222
where: identifier === 'uid' ? { uid: value } : { slug: value },
2323
include: {
2424
answers: true,
@@ -31,6 +31,22 @@ export const getQuestion = async (
3131
},
3232
});
3333

34+
// If not found, try the other identifier
35+
if (!res) {
36+
res = await prisma.questions.findUnique({
37+
where: identifier === 'uid' ? { slug: value } : { uid: value },
38+
include: {
39+
answers: true,
40+
tags: {
41+
include: {
42+
tag: true,
43+
},
44+
},
45+
QuestionResources: true,
46+
},
47+
});
48+
}
49+
3450
if (!res) {
3551
console.error('Question not found');
3652
return null;

0 commit comments

Comments
 (0)