[questions][fix] fix encounter sorting with text (#522)

ailing/undo-fix
hpkoh 2 years ago committed by GitHub
parent bd9a30f1f8
commit 6926aa41cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -327,24 +327,40 @@ export const questionsQuestionRouter = createRouter()
const { cursor } = input; const { cursor } = input;
const sortCondition = let sortCondition = undefined;
input.sortType === SortType.TOP
? [ switch (input.sortType) {
{ case SortType.TOP:
upvotes: input.sortOrder, sortCondition = [
}, {
{ upvotes: input.sortOrder,
id: input.sortOrder, },
}, {
] id: input.sortOrder,
: [ },
{ ]
lastSeenAt: input.sortOrder, break;
}, case SortType.NEW:
{ sortCondition = [
id: input.sortOrder, {
}, 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({ const questionsData = await ctx.prisma.questionsQuestion.findMany({
cursor: cursor ? { id: cursor } : undefined, cursor: cursor ? { id: cursor } : undefined,

Loading…
Cancel
Save