-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: response dto 추가 * feat: 레포지토리, 도메인 메서드 추가 * feat: 통계 조회 로직 작성 * feat: 통계 조회 컨트롤러 * fix: 평균 출석률, 과제 제출률 계산 로직 개선 * chore: spotless 적용 * chore: import 축약 수정 * chore: dto 설명 문구 수정 * chore: 변수명 total로 통일 * chore: 정적 팩토리 메서드명 컨벤션에 맞게 수정 * refactor: 과제 휴강 고려한 로직 수정 * chore: StudyWeekResponse static import 제거 * refactor: StudyStatisticsReponse 에서 0으로 나누는 케이스 고려 * fix: 연산자 오타 수정 * refactor: DTO 정적 메서드 추가 및 로직 메서드 분리 * chore: 변수명 및 메서드명 수정 * chore: soptless 적용 * chore: 변수명 개선 * chore: dto 에서 변수명 통일 * chore: isCompleted 로 메서드 명 개선
- Loading branch information
Showing
7 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyStatisticsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.gdschongik.gdsc.domain.study.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.util.List; | ||
|
||
public record StudyStatisticsResponse( | ||
@Schema(description = "스터디 전체 수강생 수") Long totalStudentCount, | ||
@Schema(description = "스터디 수료 수강생 수") Long completeStudentCount, | ||
@Schema(description = "평균 출석률") Long averageAttendanceRate, | ||
@Schema(description = "평균 과제 제출률") Long averageAssignmentSubmissionRate, | ||
@Schema(description = "스터디 수료율") Long studyCompleteRate, | ||
@Schema(description = "주차별 출석률 및 과제 제출률") List<StudyWeekStatisticsResponse> studyWeekStatisticsResponses) { | ||
|
||
public static StudyStatisticsResponse of( | ||
Long totalStudentCount, | ||
Long completeStudentCount, | ||
Long averageAttendanceRate, | ||
Long averageAssignmentSubmissionRate, | ||
List<StudyWeekStatisticsResponse> studyWeekStatisticsResponses) { | ||
return new StudyStatisticsResponse( | ||
totalStudentCount, | ||
completeStudentCount, | ||
averageAttendanceRate, | ||
averageAssignmentSubmissionRate, | ||
totalStudentCount == 0 ? 0 : Math.round(completeStudentCount / (double) totalStudentCount * 100), | ||
studyWeekStatisticsResponses); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyWeekStatisticsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.gdschongik.gdsc.domain.study.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public record StudyWeekStatisticsResponse( | ||
@Schema(description = "스터디 주차") Long week, | ||
@Schema(description = "출석률") Long attendanceRate, | ||
@Schema(description = "과제 제출률") Long assignmentSubmissionRate, | ||
@Schema(description = "과제 휴강 여부") boolean isAssignmentCanceled, | ||
@Schema(description = "수업 휴강 여부") boolean isCurriculumCanceled) { | ||
|
||
public static StudyWeekStatisticsResponse opened(Long week, Long attendanceRate, Long assignmentSubmissionRate) { | ||
return new StudyWeekStatisticsResponse(week, attendanceRate, assignmentSubmissionRate, false, false); | ||
} | ||
|
||
public static StudyWeekStatisticsResponse empty( | ||
Long week, boolean isAssignmentCanceled, boolean isCurriculumCanceled) { | ||
return new StudyWeekStatisticsResponse(week, 0L, 0L, isAssignmentCanceled, isCurriculumCanceled); | ||
} | ||
|
||
public static StudyWeekStatisticsResponse canceledWeek(Long week) { | ||
return StudyWeekStatisticsResponse.empty(week, true, true); | ||
} | ||
|
||
public static StudyWeekStatisticsResponse assignmentCanceled(Long week, Long attendanceRate) { | ||
return new StudyWeekStatisticsResponse(week, attendanceRate, 0L, true, false); | ||
} | ||
} |