mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-04-28 04:22:44 +08:00
[resumes][feat] add query for max resume upvote count
This commit is contained in:
@@ -157,4 +157,30 @@ export const resumesRouter = createRouter()
|
||||
},
|
||||
});
|
||||
},
|
||||
})
|
||||
.query('findUserMaxResumeUpvoteCount', {
|
||||
input: z.object({
|
||||
userId: z.string(),
|
||||
}),
|
||||
async resolve({ ctx, input }) {
|
||||
const highestUpvotedResume = await ctx.prisma.resumesResume.findFirst({
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
stars: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
stars: {
|
||||
_count: 'desc',
|
||||
},
|
||||
},
|
||||
where: {
|
||||
userId: input.userId,
|
||||
},
|
||||
});
|
||||
|
||||
return highestUpvotedResume?._count?.stars ?? 0;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user