diff options
Diffstat (limited to 'api/src/routes/guild-recommendations.ts')
-rw-r--r-- | api/src/routes/guild-recommendations.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/api/src/routes/guild-recommendations.ts b/api/src/routes/guild-recommendations.ts index 503b19b7..1432f39c 100644 --- a/api/src/routes/guild-recommendations.ts +++ b/api/src/routes/guild-recommendations.ts @@ -6,15 +6,18 @@ import { route } from "@fosscord/api"; const router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { - const { limit, personalization_disabled } = req.params; - var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery; + const { limit, personalization_disabled } = req.query; + var showAllGuilds = Config.get().guild.discovery.showAllGuilds; // ! this only works using SQL querys // TODO: implement this with default typeorm query // const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) }); + + const genLoadId = (size: Number) => [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join(''); + const guilds = showAllGuilds - ? await Guild.find({ take: Math.abs(Number(limit || 20)) }) - : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 100)) }); - res.send({ recommended_guilds: guilds }); + ? await Guild.find({ take: Math.abs(Number(limit || 24)) }) + : await Guild.find({ where: `"features" LIKE '%DISCOVERABLE%'`, take: Math.abs(Number(limit || 24)) }); + res.send({ recommended_guilds: guilds, load_id: `server_recs/${genLoadId(32)}`}).status(200); }); export default router; |