diff options
Diffstat (limited to 'api/src/routes/discoverable-guilds.ts')
-rw-r--r-- | api/src/routes/discoverable-guilds.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/api/src/routes/discoverable-guilds.ts b/api/src/routes/discoverable-guilds.ts index df4448df..0aa2baa9 100644 --- a/api/src/routes/discoverable-guilds.ts +++ b/api/src/routes/discoverable-guilds.ts @@ -13,12 +13,10 @@ router.get("/", route({}), async (req: Request, res: Response) => { // TODO: implement this with default typeorm query // const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) }); let guilds; - let total; if (categories == undefined) { guilds = showAllGuilds ? await Guild.find({ take: Math.abs(Number(limit || configLimit)) }) : await Guild.find({ where: `"features" LIKE '%DISCOVERABLE%'`, take: Math.abs(Number(limit || configLimit)) }); - total = guilds.length; } else { guilds = showAllGuilds ? await Guild.find({ where: `"primary_category_id" = ${categories}`, take: Math.abs(Number(limit || configLimit)) }) @@ -26,8 +24,10 @@ router.get("/", route({}), async (req: Request, res: Response) => { where: `"primary_category_id" = ${categories} AND "features" LIKE '%DISCOVERABLE%'`, take: Math.abs(Number(limit || configLimit)) }); - total = guilds.length; } + + const total = guilds ? guilds.length : undefined; + res.send({ total: total, guilds: guilds, offset: Number(offset || Config.get().guild.discovery.offset), limit: Number(limit || configLimit) }); }); |