|
|
|
@ -39,7 +39,7 @@ export const questionsQuestionRouter = createRouter()
|
|
|
|
|
{
|
|
|
|
|
id: input.sortOrder,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
case SortType.NEW:
|
|
|
|
|
sortCondition = [
|
|
|
|
@ -61,7 +61,7 @@ export const questionsQuestionRouter = createRouter()
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const questionsData = await ctx.prisma.questionsQuestion.findMany({
|
|
|
|
|
cursor: cursor ? { id: cursor } : undefined,
|
|
|
|
@ -309,9 +309,8 @@ export const questionsQuestionRouter = createRouter()
|
|
|
|
|
|
|
|
|
|
let relatedQuestionsId: Array<{ id: string }> = [];
|
|
|
|
|
|
|
|
|
|
if (input.content !== "") {
|
|
|
|
|
relatedQuestionsId = await ctx.prisma
|
|
|
|
|
.$queryRaw`
|
|
|
|
|
if (input.content !== '') {
|
|
|
|
|
relatedQuestionsId = await ctx.prisma.$queryRaw`
|
|
|
|
|
SELECT id FROM "QuestionsQuestion"
|
|
|
|
|
WHERE
|
|
|
|
|
ts_rank_cd(to_tsvector("content"), to_tsquery(${query}), 32) > 0.1
|
|
|
|
@ -319,8 +318,6 @@ export const questionsQuestionRouter = createRouter()
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const relatedQuestionsIdArray = relatedQuestionsId.map(
|
|
|
|
|
(current) => current.id,
|
|
|
|
|
);
|
|
|
|
@ -338,7 +335,7 @@ export const questionsQuestionRouter = createRouter()
|
|
|
|
|
{
|
|
|
|
|
id: input.sortOrder,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
case SortType.NEW:
|
|
|
|
|
sortCondition = [
|
|
|
|
@ -360,7 +357,7 @@ export const questionsQuestionRouter = createRouter()
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const questionsData = await ctx.prisma.questionsQuestion.findMany({
|
|
|
|
|
cursor: cursor ? { id: cursor } : undefined,
|
|
|
|
@ -391,9 +388,12 @@ export const questionsQuestionRouter = createRouter()
|
|
|
|
|
orderBy: sortCondition,
|
|
|
|
|
take: input.limit + 1,
|
|
|
|
|
where: {
|
|
|
|
|
id: input.content !== "" ? {
|
|
|
|
|
in: relatedQuestionsIdArray,
|
|
|
|
|
} : undefined,
|
|
|
|
|
id:
|
|
|
|
|
input.content !== ''
|
|
|
|
|
? {
|
|
|
|
|
in: relatedQuestionsIdArray,
|
|
|
|
|
}
|
|
|
|
|
: undefined,
|
|
|
|
|
...(input.questionTypes.length > 0
|
|
|
|
|
? {
|
|
|
|
|
questionType: {
|
|
|
|
|