diff --git a/nestjs/src/courses/course-tasks/course-tasks.service.ts b/nestjs/src/courses/course-tasks/course-tasks.service.ts index a824dd6775..9bf646f490 100644 --- a/nestjs/src/courses/course-tasks/course-tasks.service.ts +++ b/nestjs/src/courses/course-tasks/course-tasks.service.ts @@ -16,6 +16,7 @@ import * as dayjs from 'dayjs'; import { TaskResult } from '@entities/taskResult'; import { TaskInterviewResult } from '@entities/taskInterviewResult'; import { TaskSolution } from '@entities/taskSolution'; +import { StageInterview } from '@entities/index'; export enum Status { Started = 'started', @@ -73,11 +74,18 @@ export class CourseTasksService { .select('ct.id', 'id') .addSelect('COUNT(r.id)', 'resultsCount') .addSelect('COUNT(i.id)', 'interviewResultsCount') + .addSelect('COUNT(CASE WHEN si.score > 0 THEN 1 END)', 'stageInterviewResultsCount') .leftJoin(TaskResult, 'r', 'r.courseTaskId = ct.id') .leftJoin(TaskInterviewResult, 'i', 'i.courseTaskId = ct.id') + .leftJoin(StageInterview, 'si', 'si.courseTaskId = ct.id') .where('ct.courseId = :courseId', { courseId }) .groupBy('ct.id') - .getRawMany<{ id: number; resultsCount: number; interviewResultsCount: number }>(), + .getRawMany<{ + id: number; + resultsCount: number; + interviewResultsCount: number; + stageInterviewResultsCount: number; + }>(), ]); return courseTasks.map(courseTask => { const result = courseTaskResults.find(({ id }) => id === courseTask.id); @@ -85,6 +93,7 @@ export class CourseTasksService { ...courseTask, resultsCount: Number(result?.resultsCount || 0), interviewResultsCount: Number(result?.interviewResultsCount || 0), + stageInterviewResultsCount: Number(result?.stageInterviewResultsCount ?? 0), }; }); } diff --git a/nestjs/src/courses/course-tasks/dto/course-task-detailed.dto.ts b/nestjs/src/courses/course-tasks/dto/course-task-detailed.dto.ts index 28c277193c..0082b85fad 100644 --- a/nestjs/src/courses/course-tasks/dto/course-task-detailed.dto.ts +++ b/nestjs/src/courses/course-tasks/dto/course-task-detailed.dto.ts @@ -4,12 +4,19 @@ import { CourseTaskDto } from './course-task.dto'; @ApiResponse({}) export class CourseTaskDetailedDto extends CourseTaskDto { - constructor(courseTask: CourseTask & { resultsCount?: number; interviewResultsCount?: number }) { + constructor( + courseTask: CourseTask & { + resultsCount?: number; + interviewResultsCount?: number; + stageInterviewResultsCount?: number; + }, + ) { super(courseTask); this.publicAttributes = courseTask.task?.attributes?.['public'] ?? {}; this.githubRepoName = courseTask.task.githubRepoName; this.sourceGithubRepoUrl = courseTask.task.sourceGithubRepoUrl; - this.resultsCount = courseTask.resultsCount || courseTask.interviewResultsCount || 0; + this.resultsCount = + courseTask.resultsCount || courseTask.interviewResultsCount || courseTask.stageInterviewResultsCount || 0; } @ApiProperty()