fix: sort public guilds with descending members count
This commit is contained in:
parent
4d565e4f1f
commit
2f78604116
@ -18,7 +18,8 @@ const querySchema = Type.Object({
|
|||||||
export type QuerySchemaType = Static<typeof querySchema>
|
export type QuerySchemaType = Static<typeof querySchema>
|
||||||
|
|
||||||
const getServiceSchema: FastifySchema = {
|
const getServiceSchema: FastifySchema = {
|
||||||
description: 'GET all the public guilds.',
|
description:
|
||||||
|
'GET all the public guilds (ordered by descending members count).',
|
||||||
tags: ['guilds'] as string[],
|
tags: ['guilds'] as string[],
|
||||||
security: [
|
security: [
|
||||||
{
|
{
|
||||||
@ -55,7 +56,11 @@ export const getGuildsPublic: FastifyPluginAsync = async (fastify) => {
|
|||||||
}
|
}
|
||||||
const guildsRequest = await prisma.guild.findMany({
|
const guildsRequest = await prisma.guild.findMany({
|
||||||
...getPaginationOptions(request.query),
|
...getPaginationOptions(request.query),
|
||||||
orderBy: { createdAt: 'desc' },
|
orderBy: {
|
||||||
|
members: {
|
||||||
|
_count: 'desc'
|
||||||
|
}
|
||||||
|
},
|
||||||
...(request.query.search != null && {
|
...(request.query.search != null && {
|
||||||
where: {
|
where: {
|
||||||
name: { contains: request.query.search }
|
name: { contains: request.query.search }
|
||||||
|
Reference in New Issue
Block a user