mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-02-08 21:14:28 +08:00
[questions][fix] fix encounter sorting with text (#522)
This commit is contained in:
@@ -327,24 +327,40 @@ export const questionsQuestionRouter = createRouter()
|
||||
|
||||
const { cursor } = input;
|
||||
|
||||
const sortCondition =
|
||||
input.sortType === SortType.TOP
|
||||
? [
|
||||
{
|
||||
upvotes: input.sortOrder,
|
||||
},
|
||||
{
|
||||
id: input.sortOrder,
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
lastSeenAt: input.sortOrder,
|
||||
},
|
||||
{
|
||||
id: input.sortOrder,
|
||||
},
|
||||
];
|
||||
let sortCondition = undefined;
|
||||
|
||||
switch (input.sortType) {
|
||||
case SortType.TOP:
|
||||
sortCondition = [
|
||||
{
|
||||
upvotes: input.sortOrder,
|
||||
},
|
||||
{
|
||||
id: input.sortOrder,
|
||||
},
|
||||
]
|
||||
break;
|
||||
case SortType.NEW:
|
||||
sortCondition = [
|
||||
{
|
||||
lastSeenAt: input.sortOrder,
|
||||
},
|
||||
{
|
||||
id: input.sortOrder,
|
||||
},
|
||||
];
|
||||
break;
|
||||
case SortType.ENCOUNTERS:
|
||||
sortCondition = [
|
||||
{
|
||||
numEncounters: input.sortOrder,
|
||||
},
|
||||
{
|
||||
id: input.sortOrder,
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
const questionsData = await ctx.prisma.questionsQuestion.findMany({
|
||||
cursor: cursor ? { id: cursor } : undefined,
|
||||
|
||||
Reference in New Issue
Block a user