From 21fa1274e937f5cbc9d3fd92be5907789ce768b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=95=EB=85=84?= <64246800+KangNyeonKim@users.noreply.github.com> Date: Thu, 15 Dec 2022 14:41:20 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=EA=B2=B0=EA=B3=BC=20api=20test?= =?UTF-8?q?=EC=9A=A9=20mock=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/Result/Result.Test.ts | 49 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/server/src/Result/Result.Test.ts b/server/src/Result/Result.Test.ts index 9ffe05c..4f96f40 100644 --- a/server/src/Result/Result.Test.ts +++ b/server/src/Result/Result.Test.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line import/no-extraneous-dependencies import request from "supertest"; import * as dotenv from "dotenv"; import { BeforeRecover } from "typeorm"; @@ -9,47 +10,45 @@ beforeAll(async () => { await connectMongoDB(); }); describe("GET api/results/:formId", () => { - const testFormId = "6396ab6baa73534ba0a86b12"; + const testFormId = "637e2d875d07882cfce8a076"; const testResult = { - formTitle: "TEST", - totalResponseCount: 9, + formTitle: "Form Mock Data", + totalResponseCount: 28363, acceptResponse: true, questionResultDict: { "1": { type: "checkbox", - questionTitle: "q1", - responseCount: 9, + questionTitle: "좋아하는 동물", + responseCount: 12389, answerTotal: { - a1: 2, - a2: 1, - a3: 1, - a4: 2, - a5: 3, + dog: 3114, + cat: 3059, + rabbit: 3163, + question1: 3053, }, }, "2": { type: "multiple", - questionTitle: "q2", - responseCount: 9, + questionTitle: "좋아하는 음식", + responseCount: 12389, answerTotal: { - a1: 6, - a2: 9, - a3: 9, - a4: 9, - a5: 9, + pizza: 3114, + chicken: 3059, + kimbap: 3163, + bread: 0, + question2: 3053, }, }, "3": { type: "paragraph", - questionTitle: "q3", - responseCount: 9, + questionTitle: "의견을 남겨주세요", + responseCount: 12389, answerTotal: { - "2": 1, - "3": 2, - "4": 1, - "5": 2, - "6": 2, - a1: 1, + answer1: 3110, + answer2: 3059, + answer3: 3163, + question3: 3053, + 의견1: 4, }, }, }, From 4dd9972a6f943a19b890bbeacf20c92a631f8851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=95=EB=85=84?= <64246800+KangNyeonKim@users.noreply.github.com> Date: Thu, 15 Dec 2022 16:38:52 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20result=20Service=20private=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=20/=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/Result/Result.Service.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/Result/Result.Service.ts b/server/src/Result/Result.Service.ts index 98e1c6a..02f1270 100644 --- a/server/src/Result/Result.Service.ts +++ b/server/src/Result/Result.Service.ts @@ -1,13 +1,12 @@ -import { format } from "path"; import { Response, FormResult, Answer } from "./types/Result.Interface"; import Form from "../Form/Form.Model"; import FormResponse from "../Response/Response.Model"; import BadRequestException from "../Common/Exceptions/BadRequest.Exception"; export default class ResultService { - form: any; + private form: any; - responseList: Array; + private responseList: Array; result: FormResult; @@ -22,6 +21,7 @@ export default class ResultService { }; } + // formId에 해당하는 설문지와 응답들을 불러온다. public async init(formId: string) { this.form = undefined; this.responseList = []; @@ -65,21 +65,25 @@ export default class ResultService { return resultDict; } + // 설문 응답 리스트를 순회하며 결과를 집계한다 formResult(): FormResult { this.responseList.forEach((response) => this.aggregateResponse(response)); return this.result; } + // 설문 응답내의 문제 리스트를 순회하며 결과를 집계한다. aggregateResponse(response: Response) { response.answer_list.forEach((answer: Answer) => this.aggregateAnswer(answer)); } + // 문제 별 응답개수를 카운트하고 문제 내의 지문들을 순회화며 결과를 집계한다. aggregateAnswer(answer: Answer) { if (!((answer.question_id as number) in this.result.questionResultDict)) return; this.result.questionResultDict[answer.question_id].responseCount += 1; answer.answer.forEach((option: string) => this.countOptionSelected(option, answer.question_id)); } + // 지문 별 응답개수를 카운트한다. countOptionSelected(option: string, questionId: number) { if (option in this.result.questionResultDict[questionId].answerTotal) { this.result.questionResultDict[questionId].answerTotal[option] += 1; From 967ed42ff830f1780081a5dba34cd519ea49078f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=95=EB=85=84?= <64246800+KangNyeonKim@users.noreply.github.com> Date: Thu, 15 Dec 2022 16:39:53 +0900 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=ED=83=88=ED=87=B4=EB=90=9C=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=EC=9D=98=20=EC=BF=A0=ED=82=A4=EB=A1=9C=20?= =?UTF-8?q?=EC=A0=91=EA=B7=BC=EC=8B=9C=20=EB=B0=9C=EC=83=9D=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=97=90=EB=9F=AC=20=ED=95=B8=EB=93=A4=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/Form/Form.Service.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/src/Form/Form.Service.ts b/server/src/Form/Form.Service.ts index 2164ca3..9b16527 100644 --- a/server/src/Form/Form.Service.ts +++ b/server/src/Form/Form.Service.ts @@ -34,6 +34,9 @@ class FormService { .catch(() => { throw new NotFoundException(); }); + if (!rawFormList) { + throw new NotFoundException(); + } const formList = rawFormList.map((form: any) => { return { _id: `${form._id}`, From 7b555c9be327782e17d51fdae19ce1794cfeff12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B0=95=EB=85=84?= <64246800+KangNyeonKim@users.noreply.github.com> Date: Thu, 15 Dec 2022 17:56:26 +0900 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20favicon=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=EC=BD=98=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/public/favicon.ico | Bin 0 -> 1150 bytes client/public/index.html | 2 ++ 2 files changed, 2 insertions(+) create mode 100644 client/public/favicon.ico diff --git a/client/public/favicon.ico b/client/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..f6f66f8fa3cc5daa2df68adc901123ce42cc446d GIT binary patch literal 1150 zcmZQzU<5(|0R|wcz>vYhz#zuJz@P!dKp~(AL>x#lFaYIVFheky4INAFD zh9s;1870QK&!2>X9_PSgK0v+9Ak0gO-2sQte!&*T3_pgg{?+K^=V z|HS0-|JT;d{C|Ey`~PFT`Tq~KXZ*juVfO#Mwb5XA;nkmL`Ttm7;s3L<8~>l4QTPA& z#FGDq+S2}C-#F+0_Ixj(eoNeL0J;sN_Ttjs{}&c@f$_Py&HqnKEQPS=wf;Xhx8?tV zrbO&!!1OQf`G0Xq&;QHIC;Y#(wD13wm6QHoT-^Qt>YC|b@dHgsz_7(04jW+Z2ZrB; zg`NK|0QDW~EBJqAW;9hxVo)4{<1g18yT8%XKhSUFrXPH9J6Ppl + + BoostForm