Skip to content

Commit

Permalink
⚡️ :: (#178) userAnswerCount 함수
Browse files Browse the repository at this point in the history
  • Loading branch information
flower1465 committed Jul 11, 2022
1 parent 10959dc commit da230aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/domain/repositories/video.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export interface VideoRepository {
countAnswerVideo(userId: number): Promise<GetCountUserQuestionPresenter>;
videoViews(videoId: number): Promise<void>;
userQuestionCount(userId: number): Promise<number>;
userAnswerCount(userId: number): Promise<number>;
}
11 changes: 11 additions & 0 deletions src/infrastructure/repositories/video.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,15 @@ export class DatabaseVideoRepository implements VideoRepository {

return userQuestionCnt;
}

async userAnswerCount(userId: number): Promise<number> {
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;
}
}

0 comments on commit da230aa

Please sign in to comment.