From 9c5acbd6e4ec791aeda85596c2be7ea6c9f79c5f Mon Sep 17 00:00:00 2001 From: zkldi Date: Tue, 27 Apr 2021 00:13:45 +0100 Subject: [PATCH] change how namegen worked to be sync --- .../core/sessions/name-generation.ts | 41 +++---------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/server/src/score-import/framework/core/sessions/name-generation.ts b/server/src/score-import/framework/core/sessions/name-generation.ts index f6255cf64..68fee0e43 100644 --- a/server/src/score-import/framework/core/sessions/name-generation.ts +++ b/server/src/score-import/framework/core/sessions/name-generation.ts @@ -1,38 +1,9 @@ -import db from "../../../../db/db"; -import { KtLogger } from "../../../../types"; +import { GetRandomAdjective, GetRandomNoun } from "../../../../data/words"; -export async function GenerateRandomSessionName(logger: KtLogger) { - let adjectives = await db.adjectives.aggregate([ - { - $sample: { - size: 2, - }, - }, - ]); +export function GenerateRandomSessionName() { + let adj1 = GetRandomAdjective(); + let adj2 = GetRandomAdjective(); + let noun = GetRandomNoun(); - let nouns = await db.nouns.aggregate([ - { - $sample: { - size: 1, - }, - }, - ]); - - if (adjectives.length < 2) { - logger.severe( - `Could not source 2 adjectives from the adjectives DB. Filling in with defaults, but this should be investigated.` - ); - - adjectives = ["Ambient", "Scary"]; - } - - if (nouns.length < 1) { - logger.severe( - `Could not source a noun from the noun DB. Filling in with defaults, but this should be investigated.` - ); - - nouns = ["Noise"]; - } - - return `${adjectives[0].text} ${adjectives[1].text} ${nouns[0].text}`; + return `${adj1} ${adj2} ${noun}`; }