From faa1996494bae03174e6514c3c14dfad5e28a6f6 Mon Sep 17 00:00:00 2001 From: Ungs Date: Mon, 25 Nov 2024 20:50:26 +0900 Subject: [PATCH] fix : get word logic --- src/dictionary/dictionary.service.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/dictionary/dictionary.service.ts b/src/dictionary/dictionary.service.ts index 181031e..15317f2 100644 --- a/src/dictionary/dictionary.service.ts +++ b/src/dictionary/dictionary.service.ts @@ -50,14 +50,16 @@ export class DictionaryService { const list: string[] = await this.prisma .$queryRaw`SELECT _id FROM "public"."wakttu_ko" WHERE LENGTH(_id) = ${length} AND wakta = true ORDER BY random() LIMIT 1`; - let isMannerSafe = true; - list[0]['_id'].split('').map(async (word) => { - isMannerSafe = await this.checkManner(word); - }); - if (isMannerSafe) { - return list[0]; // 매너 검사를 통과한 단어 반환 + const word = list[0]['_id']; + + for (const char of word.split('')) { + const isSafe = await this.checkManner(char); + if (!isSafe) { + return '우리모두품어놀자'.slice(0, length); + } } - return '우리모두품어놀자'.slice(0, length); + + return word; } catch (error) { throw new Error(`단어 가져오기 중 오류 발생: ${error.message}`); }