Skip to content

Commit

Permalink
chore: 변수명 total로 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
kckc0608 committed Oct 15, 2024
1 parent 7a930db commit 9c9321e
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public StudyStatisticsResponse getStudyStatistics(Long studyId) {
studyValidator.validateStudyMentor(currentMember, study);

List<StudyHistory> studyHistories = studyHistoryRepository.findAllByStudyId(studyId);
long wholeStudentCount = studyHistories.size();
long totalStudentCount = studyHistories.size();
long studyCompleteStudentCount =
studyHistories.stream().filter(StudyHistory::isComplete).count();

Expand All @@ -141,30 +141,30 @@ public StudyStatisticsResponse getStudyStatistics(Long studyId) {
.count();

List<StudyWeekStatisticsResponse> studyWeekStatisticsResponses =
calculateStudyWeekStatistics(studyDetails, wholeStudentCount);
calculateStudyWeekStatistics(studyDetails, totalStudentCount);

long averageAttendanceRate = calculateAverageWeekAttendanceRate(studyWeekStatisticsResponses, openedWeekCount);
long averageAssignmentSubmitRate =
calculateAverageWeekAssignmentSubmitRate(studyWeekStatisticsResponses, openedWeekCount);

return StudyStatisticsResponse.of(
wholeStudentCount,
totalStudentCount,
studyCompleteStudentCount,
averageAttendanceRate,
averageAssignmentSubmitRate,
studyWeekStatisticsResponses);
}

private List<StudyWeekStatisticsResponse> calculateStudyWeekStatistics(
List<StudyDetail> studyDetails, Long wholeStudentCount) {
List<StudyDetail> studyDetails, Long totalStudentCount) {

return studyDetails.stream()
.map((studyDetail -> {
if (!studyDetail.getCurriculum().isOpen()) {
return StudyWeekStatisticsResponse.createCanceledWeekStatistics(studyDetail.getWeek());
}

if (wholeStudentCount == 0) {
if (totalStudentCount == 0) {
return StudyWeekStatisticsResponse.createOpenedWeekStatistics(studyDetail.getWeek(), 0L, 0L);
}

Expand All @@ -174,8 +174,8 @@ private List<StudyWeekStatisticsResponse> calculateStudyWeekStatistics(

return StudyWeekStatisticsResponse.createOpenedWeekStatistics(
studyDetail.getWeek(),
Math.round(attendanceCount / (double) wholeStudentCount * 100),
Math.round(assignmentCount / (double) wholeStudentCount * 100));
Math.round(attendanceCount / (double) totalStudentCount * 100),
Math.round(assignmentCount / (double) totalStudentCount * 100));
}))
.toList();
}
Expand Down

0 comments on commit 9c9321e

Please sign in to comment.