From b18bea5d2f18df872131008affc5de48508acc0e Mon Sep 17 00:00:00 2001 From: kckc0608 Date: Wed, 30 Oct 2024 21:42:17 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B0=8F=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=AA=85=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 --- .../application/MentorStudyDetailService.java | 26 +++++++++---------- .../dto/response/StudyStatisticsResponse.java | 6 ++--- .../response/StudyWeekStatisticsResponse.java | 16 ++++++------ 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java index 6bca2c427..0df5abe7c 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java @@ -133,7 +133,7 @@ public StudyStatisticsResponse getStudyStatistics(Long studyId) { studyValidator.validateStudyMentor(currentMember, study); long totalStudentCount = studyHistories.size(); - long studyCompleteStudentCount = + long studyCompletedStudentCount = studyHistories.stream().filter(StudyHistory::isComplete).count(); List studyWeekStatisticsResponses = studyDetails.stream() @@ -141,13 +141,13 @@ public StudyStatisticsResponse getStudyStatistics(Long studyId) { .toList(); long averageAttendanceRate = calculateAverageWeekAttendanceRate(studyWeekStatisticsResponses); - long averageAssignmentSubmitRate = calculateAverageWeekAssignmentSubmitRate(studyWeekStatisticsResponses); + long averageAssignmentSubmissionRate = calculateAverageWeekAssignmentSubmissionRate(studyWeekStatisticsResponses); return StudyStatisticsResponse.of( totalStudentCount, - studyCompleteStudentCount, + studyCompletedStudentCount, averageAttendanceRate, - averageAssignmentSubmitRate, + averageAssignmentSubmissionRate, studyWeekStatisticsResponses); } @@ -156,25 +156,25 @@ private StudyWeekStatisticsResponse calculateWeekStatistics(StudyDetail studyDet boolean isCanceledAssignment = !studyDetail.getAssignment().isOpen() || isCanceledWeek; if (totalStudentCount == 0) { - return StudyWeekStatisticsResponse.emptyOf(studyDetail.getWeek(), isCanceledAssignment, isCanceledWeek); + return StudyWeekStatisticsResponse.empty(studyDetail.getWeek(), isCanceledAssignment, isCanceledWeek); } if (isCanceledWeek) { - return StudyWeekStatisticsResponse.canceledWeekFrom(studyDetail.getWeek()); + return StudyWeekStatisticsResponse.canceledWeek(studyDetail.getWeek()); } long attendanceCount = attendanceRepository.countByStudyDetailId(studyDetail.getId()); long attendanceRate = Math.round(attendanceCount / (double) totalStudentCount * 100); if (isCanceledAssignment) { - return StudyWeekStatisticsResponse.canceledAssignmentOf(studyDetail.getWeek(), attendanceRate); + return StudyWeekStatisticsResponse.assignmentCanceled(studyDetail.getWeek(), attendanceRate); } long assignmentCount = assignmentHistoryRepository.countByStudyDetailIdAndSubmissionStatusEquals(studyDetail.getId(), SUCCESS); long assignmentRate = Math.round(assignmentCount / (double) totalStudentCount * 100); - return StudyWeekStatisticsResponse.openedOf(studyDetail.getWeek(), attendanceRate, assignmentRate); + return StudyWeekStatisticsResponse.opened(studyDetail.getWeek(), attendanceRate, assignmentRate); } private long calculateAverageWeekAttendanceRate(List studyWeekStatisticsResponses) { @@ -188,15 +188,15 @@ private long calculateAverageWeekAttendanceRate(List studyWeekStatisticsResponses) { - double averageAssignmentSubmitRate = studyWeekStatisticsResponses.stream() - .filter(studyWeekStatistics -> !studyWeekStatistics.isCanceledAssignment()) - .mapToLong(StudyWeekStatisticsResponse::assignmentSubmitRate) + double averageAssignmentSubmissionRate = studyWeekStatisticsResponses.stream() + .filter(studyWeekStatistics -> !studyWeekStatistics.isAssignmentCanceled()) + .mapToLong(StudyWeekStatisticsResponse::assignmentSubmissionRate) .average() .orElse(0); - return Math.round(averageAssignmentSubmitRate); + return Math.round(averageAssignmentSubmissionRate); } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyStatisticsResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyStatisticsResponse.java index ab3319234..3b481edfe 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyStatisticsResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyStatisticsResponse.java @@ -7,7 +7,7 @@ public record StudyStatisticsResponse( @Schema(description = "스터디 전체 수강생 수") Long totalStudentCount, @Schema(description = "스터디 수료 수강생 수") Long completeStudentCount, @Schema(description = "평균 출석률") Long averageAttendanceRate, - @Schema(description = "평균 과제 제출률") Long averageAssignmentSubmitRate, + @Schema(description = "평균 과제 제출률") Long averageAssignmentSubmissionRate, @Schema(description = "스터디 수료율") Long studyCompleteRate, @Schema(description = "주차별 출석률 및 과제 제출률") List studyWeekStatisticsResponses) { @@ -15,13 +15,13 @@ public static StudyStatisticsResponse of( Long totalStudentCount, Long completeStudentCount, Long averageAttendanceRate, - Long averageAssignmentSubmitRate, + Long averageAssignmentSubmissionRate, List studyWeekStatisticsResponses) { return new StudyStatisticsResponse( totalStudentCount, completeStudentCount, averageAttendanceRate, - averageAssignmentSubmitRate, + averageAssignmentSubmissionRate, totalStudentCount == 0 ? 0 : Math.round(completeStudentCount / (double) totalStudentCount * 100), studyWeekStatisticsResponses); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyWeekStatisticsResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyWeekStatisticsResponse.java index dd85993be..04610f153 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyWeekStatisticsResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyWeekStatisticsResponse.java @@ -5,23 +5,23 @@ public record StudyWeekStatisticsResponse( @Schema(description = "스터디 주차") Long week, @Schema(description = "출석률") Long attendanceRate, - @Schema(description = "과제 제출률") Long assignmentSubmitRate, - @Schema(description = "과제 휴강 여부") boolean isCanceledAssignment, + @Schema(description = "과제 제출률") Long assignmentSubmissionRate, + @Schema(description = "과제 휴강 여부") boolean isAssignmentCanceled, @Schema(description = "스터디 휴강 여부") boolean isCanceledWeek) { - public static StudyWeekStatisticsResponse openedOf(Long week, Long attendanceRate, Long assignmentSubmitRate) { - return new StudyWeekStatisticsResponse(week, attendanceRate, assignmentSubmitRate, false, false); + public static StudyWeekStatisticsResponse opened(Long week, Long attendanceRate, Long assignmentSubmissionRate) { + return new StudyWeekStatisticsResponse(week, attendanceRate, assignmentSubmissionRate, false, false); } - public static StudyWeekStatisticsResponse emptyOf(Long week, boolean isCanceledAssignment, boolean isCanceledWeek) { + public static StudyWeekStatisticsResponse empty(Long week, boolean isCanceledAssignment, boolean isCanceledWeek) { return new StudyWeekStatisticsResponse(week, 0L, 0L, isCanceledAssignment, isCanceledWeek); } - public static StudyWeekStatisticsResponse canceledWeekFrom(Long week) { - return StudyWeekStatisticsResponse.emptyOf(week, true, true); + public static StudyWeekStatisticsResponse canceledWeek(Long week) { + return StudyWeekStatisticsResponse.empty(week, true, true); } - public static StudyWeekStatisticsResponse canceledAssignmentOf(Long week, Long attendanceRate) { + public static StudyWeekStatisticsResponse assignmentCanceled(Long week, Long attendanceRate) { return new StudyWeekStatisticsResponse(week, attendanceRate, 0L, true, false); } }