Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 변경된 출석 점수 반영 #465

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

@Slf4j
public enum ScoreType {
ATTENDANCE("전체 세미나 출석", 0.0),
ABSENT("전체 세미나 결석", -1.0),
LATE("전체 세미나 지각", -0.5),
ATTENDANCE("전체 세미나 출석", 1.0),
ABSENT("전체 세미나 결석", 0.0),
LATE("전체 세미나 지각", 0.5),
DEPLOY_FAILURE("프로젝트 배포 실패", -0.5),
@Deprecated
DEPLOY_SUCCESS("프로젝트 배포 성공", 1.0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,36 @@ public ScoreHistory createByAttendances(

/**
* 출석 결과로 최종 출석 결과를 생성한다.
* TODO: 리팩토링 진행 by @hocaron
*/
private ScoreType getScoreTypeByAttendances(
List<Event> events,
List<Attendance> attendances
) {
ScoreType scoreType = ScoreType.ATTENDANCE;
long attendanceCount = countAttendance(attendances);
long lateCount = countLate(attendances, attendanceCount);
long absentCount = countAbsent(events, attendances);

final long attendanceNumber = attendances.stream()
if (absentCount > 0) {
return ScoreType.ABSENT; // 결석이 하나 이상인 경우
}
if (lateCount > 0) {
return ScoreType.LATE; // 지각이 하나 이상인 경우
}
return ScoreType.ATTENDANCE; // 모두 출석한 경우
}

private long countAttendance(List<Attendance> attendances) {
return attendances.stream()
.filter(attendance -> attendance.getStatus() == AttendanceStatus.ATTENDANCE)
.count();
final long lateNumber = attendances.size() - attendanceNumber;
final long absentNumber = events.size() - attendances.size();
}

if (absentNumber > 0) { // 결석이 하나 이상인 경우
scoreType = ScoreType.ABSENT;
} else if (lateNumber > 0) { // 지각이 하나 이상인 경우
scoreType = ScoreType.LATE;
}
private long countLate(List<Attendance> attendances, long attendanceNumber) {
return attendances.size() - attendanceNumber;
}

return scoreType;
private long countAbsent(List<Event> events, List<Attendance> attendances) {
return events.size() - attendances.size();
}

public void deleteAll(List<ScoreHistory> scoreHistories) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import kr.mashup.branding.domain.member.MemberGeneration;
import kr.mashup.branding.domain.member.Platform;
import kr.mashup.branding.domain.member.exception.MemberInvalidInviteCodeException;
import kr.mashup.branding.domain.scorehistory.ScoreHistory;
import kr.mashup.branding.domain.scorehistory.ScoreType;
import kr.mashup.branding.security.JwtService;
import kr.mashup.branding.service.invite.InviteService;
import kr.mashup.branding.service.member.MemberCreateDto;
Expand All @@ -20,7 +18,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;


Expand Down Expand Up @@ -88,10 +85,6 @@ public AccessResponse signUp(SignUpRequest request) {
final String token = getToken(member);
Platform latestPlatform = memberService.getLatestPlatform(member);

// 회원가입 시점에 기본 활동 점수 부여
ScoreHistory scoreHistory = ScoreHistory.of(ScoreType.DEFAULT, member, LocalDateTime.now(), "", generation, null);
scoreHistoryService.save(scoreHistory);

return AccessResponse.of(member,latestPlatform, token);
}

Expand Down
Loading