mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-07-17 03:50:44 +08:00
[questions][fix] encounter last seen sorting (#530)
Co-authored-by: Jeff Sieu <jeffsy00@gmail.com>
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user