From 2f78604116c1f95d9c73438cf87701e80c58533e Mon Sep 17 00:00:00 2001 From: Divlo Date: Wed, 29 Jun 2022 04:16:48 +0000 Subject: [PATCH] fix: sort public guilds with descending members count --- src/services/guilds/public/get.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/services/guilds/public/get.ts b/src/services/guilds/public/get.ts index 014266a..46ab868 100644 --- a/src/services/guilds/public/get.ts +++ b/src/services/guilds/public/get.ts @@ -18,7 +18,8 @@ const querySchema = Type.Object({ export type QuerySchemaType = Static 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 }