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