From da230aa0c2e302525438c0aedea37730ebd4324f Mon Sep 17 00:00:00 2001 From: Seung jun Date: Mon, 11 Jul 2022 11:41:01 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#178)=20userAnswerCo?= =?UTF-8?q?unt=20=ED=95=A8=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/repositories/video.repository.ts | 1 + src/infrastructure/repositories/video.repository.ts | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/domain/repositories/video.repository.ts b/src/domain/repositories/video.repository.ts index 869aa23..738818e 100644 --- a/src/domain/repositories/video.repository.ts +++ b/src/domain/repositories/video.repository.ts @@ -29,4 +29,5 @@ export interface VideoRepository { countAnswerVideo(userId: number): Promise; videoViews(videoId: number): Promise; userQuestionCount(userId: number): Promise; + userAnswerCount(userId: number): Promise; } diff --git a/src/infrastructure/repositories/video.repository.ts b/src/infrastructure/repositories/video.repository.ts index eb1080c..40dc9cb 100644 --- a/src/infrastructure/repositories/video.repository.ts +++ b/src/infrastructure/repositories/video.repository.ts @@ -524,4 +524,15 @@ export class DatabaseVideoRepository implements VideoRepository { return userQuestionCnt; } + + async userAnswerCount(userId: number): Promise { + const userAnswerCnt: number = await this.videoEntityRepository + .createQueryBuilder('video') + .select('video.id', 'videoId') + .where('video.user_id = :user_id', { user_id: userId }) + .andWhere('video.question IS NOT NULL') + .getCount(); + + return userAnswerCnt; + } }