2
1
mirror of https://github.com/Thream/api.git synced 2024-07-06 12:50:12 +02:00

fix: sort public guilds with descending members count

This commit is contained in:
Divlo 2022-06-29 04:16:48 +00:00
parent 4d565e4f1f
commit 2f78604116
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9

View File

@ -18,7 +18,8 @@ const querySchema = Type.Object({
export type QuerySchemaType = Static<typeof querySchema>
const getServiceSchema: FastifySchema = {
description: 'GET all the public guilds.',
description:
'GET all the public guilds (ordered by descending members count).',
tags: ['guilds'] as string[],
security: [
{
@ -55,7 +56,11 @@ export const getGuildsPublic: FastifyPluginAsync = async (fastify) => {
}
const guildsRequest = await prisma.guild.findMany({
...getPaginationOptions(request.query),
orderBy: { createdAt: 'desc' },
orderBy: {
members: {
_count: 'desc'
}
},
...(request.query.search != null && {
where: {
name: { contains: request.query.search }