-
Notifications
You must be signed in to change notification settings - Fork 1
[FIX] 출석체크 시 벌점 가중치 부여 로직 추가 #291
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,7 @@ public class AttendService | |
| private final ProgramRepository programRepository; | ||
| private final ProgramEntityConverter programEntityConverter; | ||
| private final AttendCountCalculate attendCountCalculate; | ||
| private final AttendWeightCalculator attendWeightCalculator; | ||
| private final AttendPenaltyResponseConverter attendPenaltyResponseConverter; | ||
| private final ProgramRankCounterRepository programRankCounterRepository; | ||
| private final SemesterPeriodProvider semesterPeriodProvider; | ||
|
|
@@ -145,13 +146,7 @@ public ChangeAttendStatusResponse changeStatus(final Long memberId, final Long p | |
|
|
||
| validateAttend(program, model); | ||
|
|
||
| AttendModel changedModel = model.changeStatus(program.getAttendMode().getMode()); | ||
|
|
||
| if (changedModel.getStatus().equals("attend")) { | ||
| Long rank = getNextRank(programId); | ||
| changedModel.setRank(rank); | ||
| } | ||
|
|
||
| AttendModel changedModel = updateAttendStatus(model, program); | ||
| AttendEntity updated = attendRepository.save(attendEntityConverter.toEntity(changedModel)); | ||
|
|
||
| String name = queryMemberService.getName(memberId); | ||
|
|
@@ -403,6 +398,26 @@ public PageResponse<MemberStatistics> getStatistics( | |
| return new PageResponse<>(Page.empty(PageRequest.of(page - 1, size))); | ||
| } | ||
|
|
||
| private AttendModel updateAttendStatus(AttendModel model, ProgramModel program) { | ||
| // 현재 출석 모드 가져오기 | ||
| ProgramAttendMode attendMode = program.getAttendMode(); | ||
| AttendStatus attendStatus = AttendStatus.find(attendMode.getMode()); | ||
|
|
||
| // 상태 바꾸기 | ||
| AttendModel changedModel = model.changeStatus(attendMode.getMode()); | ||
| // 벌점 반영하기 | ||
| if (attendStatus == AttendStatus.ABSENT || attendStatus == AttendStatus.LATE) | ||
| changedModel.setPenaltyScore( | ||
| attendWeightCalculator.calculateTotalScore(List.of(attendStatus))); | ||
|
|
||
|
Comment on lines
+409
to
+412
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainABSENT 벌점 분기 도달 불가 가능성 + 벌점 덮어쓰기 의도 확인
명시적 분기로 의도를 드러내는 것을 권장합니다. 적용 예시(diff): - // 벌점 반영하기
- if (attendStatus == AttendStatus.ABSENT || attendStatus == AttendStatus.LATE)
- changedModel.setPenaltyScore(
- attendWeightCalculator.calculateTotalScore(List.of(attendStatus)));
+ // 벌점 반영하기
+ switch (attendStatus) {
+ case LATE:
+ // 단건 가중치라면 List.of(AttendStatus.LATE) 그대로 사용
+ changedModel.setPenaltyScore(
+ attendWeightCalculator.calculateTotalScore(List.of(AttendStatus.LATE)));
+ break;
+ case ATTEND:
+ // 참석 시 벌점 초기화가 요구사항이면 유지, 아니라면 제거
+ changedModel.setPenaltyScore(0L);
+ break;
+ default:
+ // ABSENT는 별도 마감/배치 로직에서 처리된다면 여기서는 no-op
+ break;
+ }추가 확인 스크립트(ABSENT 벌점 반영 경로 탐색): 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== ABSENT 벌점 관련 코드 경로 탐색 =="
rg -nC3 -P 'ABSENT|setPenaltyScore|calculateTotalScore|AttendWeightCalculator' --type=javaLength of output: 12094 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Show AttendService.java (first 800 lines with numbers) =="
nl -ba eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java | sed -n '1,800p'Length of output: 101 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Locate files =="
attend_service_file=$(rg -n --hidden -S "^public class AttendService\b" --type java | head -n1 | cut -d: -f1 || true)
attend_model_file=$(rg -n --hidden -S "^public class AttendModel\b" --type java | head -n1 | cut -d: -f1 || true)
attend_calc_file=$(rg -n --hidden -S "^public class AttendWeightCalculator\b" --type java | head -n1 | cut -d: -f1 || true)
program_quit_file=$(rg -n --hidden -S "^public class ProgramQuitService\b" --type java | head -n1 | cut -d: -f1 || true)
attend_repo_file=$(rg -n --hidden -S "interface .*AttendRepository|interface AttendRepository" --type java | head -n1 | cut -d: -f1 || true)
attend_count_calc_file=$(rg -n --hidden -S "^public class AttendCountCalculate\b" --type java | head -n1 | cut -d: -f1 || true)
echo "AttendService: $attend_service_file"
echo "AttendModel: $attend_model_file"
echo "AttendWeightCalculator: $attend_calc_file"
echo "ProgramQuitService: $program_quit_file"
echo "AttendRepository: $attend_repo_file"
echo "AttendCountCalculate: $attend_count_calc_file"
echo
echo "== Show AttendService (around lines 350-440) =="
if [ -n "$attend_service_file" ] && [ -f "$attend_service_file" ]; then
sed -n '340,440p' "$attend_service_file"
else
echo "AttendService file not found"
fi
echo
echo "== Show AttendModel (full) =="
if [ -n "$attend_model_file" ] && [ -f "$attend_model_file" ]; then
sed -n '1,240p' "$attend_model_file"
else
echo "AttendModel file not found"
fi
echo
echo "== Show AttendWeightCalculator (full) =="
if [ -n "$attend_calc_file" ] && [ -f "$attend_calc_file" ]; then
sed -n '1,240p' "$attend_calc_file"
else
echo "AttendWeightCalculator file not found"
fi
echo
echo "== Show ProgramQuitService (around lines 1-160) =="
if [ -n "$program_quit_file" ] && [ -f "$program_quit_file" ]; then
sed -n '1,240p' "$program_quit_file"
else
echo "ProgramQuitService file not found"
fi
echo
echo "== Show AttendRepository (any match) =="
if [ -n "$attend_repo_file" ] && [ -f "$attend_repo_file" ]; then
sed -n '1,240p' "$attend_repo_file"
else
rg -n --hidden -S "updateAttendStatusByProgramId|updateAttendStatus" --type java || true
fi
echo
echo "== Show AttendCountCalculate (full) =="
if [ -n "$attend_count_calc_file" ] && [ -f "$attend_count_calc_file" ]; then
sed -n '1,240p' "$attend_count_calc_file"
else
echo "AttendCountCalculate file not found"
fiLength of output: 13525 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== ProgramAttendMode 정의 위치 검색 =="
rg -n --hidden -S "enum ProgramAttendMode|public enum ProgramAttendMode" --type java || true
echo
echo "== Show ProgramAttendMode file =="
rg -n --hidden -S "enum ProgramAttendMode|public enum ProgramAttendMode" --type java | head -n1 | cut -d: -f1 | xargs -r sed -n '1,240p'
echo
echo "== Show AttendEntity =="
rg -n --hidden -S "class AttendEntity" --type java | head -n1 | cut -d: -f1 | xargs -r sed -n '1,240p'
echo
echo "== Search for calculateTotalScore / setPenaltyScore usages =="
rg -n --hidden -S "calculateTotalScore|setPenaltyScore" --type java || true
echo
echo "== Search for code handling ABSENT penalty elsewhere =="
rg -n --hidden -S "ABSENT.*penal|penal.*ABSENT|penaltyScore|penalty point|penaltyPoint|updateAttendStatusByProgramId" --type java || true
echo
echo "== Search for places that create/update AttendEntity penaltyScore field =="
rg -n --hidden -S "penaltyScore" --type java || true
echo
echo "== Show AttendRepository.updateAttendStatusByProgramId implementation (persistence layer) =="
rg -n --hidden -S "updateAttendStatusByProgramId" --type java -n || true
rg -n --hidden -S "updateAttendStatusByProgramId" --type sql || trueLength of output: 11722 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Show persistence AttendRepository =="
sed -n '1,240p' eeos/src/main/java/com/blackcompany/eeos/target/persistence/AttendRepository.javaLength of output: 4577 ABSENT 분기 불필요 — 배치로 상태 전환 시 벌점이 반영되지 않음(수정 필요)
권장 조치:
🤖 Prompt for AI Agents |
||
| if (attendStatus == AttendStatus.ATTEND) { | ||
| Long rank = getNextRank(program.getId()); | ||
| changedModel.setRank(rank); | ||
| } | ||
|
|
||
| return changedModel; | ||
| } | ||
|
|
||
| private List<AttendModel> findMyAttends(List<ProgramModel> programs) { | ||
| Long memberId = RequestScope.getMemberId(); | ||
| return attendRepository | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
ProgramAttendMode → AttendStatus 매핑/케이스 일치 여부 확인
attendMode.getMode()를 String으로 받아 AttendStatus.find로 변환합니다. 모드 문자열과 AttendStatus의 내부 문자열 표현(대소문자/별칭)이 1:1로 일치하는지 검증이 필요합니다.
점검 스크립트:
🏁 Script executed:
Length of output: 18723
🏁 Script executed:
Length of output: 1261
'END' 모드가 AttendStatus에 없음 — AttendStatus.find 호출 시 예외 발생
ProgramAttendMode.getMode()가 "attend"|"late"|"end"을 반환하는데 "end"는 AttendStatus(허용값: "attend","absent","late","nonResponse","nonRelated")에 없어 AttendStatus.find(attendMode.getMode()) 호출이 NotFoundAttendStatusException을 던집니다.
위치: eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java (updateAttendStatus 호출부, 약 401–411행); 관련 파일: ProgramAttendMode.java, AttendStatus.java.
해결안(중 택1):
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
음 저 함수를 호출하기 전에, AttendStatus 가 END인 경우는 이미 validate 함수를 호출해서 미리 검증하고 있어
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
@rlajm1203 맞습니다! 코드를 다시 확인해보니
changeStatus메서드에서validateAttend(program, model)를 먼저 호출하고, 이 함수가programModel.getAttendMode().equals(ProgramAttendMode.END)인 경우NotStartAttendException을 던져서updateAttendStatus가 호출되기 전에 이미 차단하고 있네요.따라서
updateAttendStatus함수는 실제로ProgramAttendMode.END케이스를 만나지 않게 되어 있어서 제가 지적한 문제는 발생하지 않을 것 같습니다. 검증 로직이 잘 되어 있군요! 😊thinking rabbit
🏁 Script executed:
Length of output: 2530
@rlajm1203 완전히 맞습니다! 스크립트 결과를 보니 확실히 검증되었네요.
changeStatus메서드에서:validateAttend(program, model)먼저 호출updateAttendStatus(model, program)나중에 호출그리고
validateAttend함수 (Line 432)에서:이렇게
END모드일 때 예외를 던져서updateAttendStatus가 호출되기 전에 이미 차단하고 있군요. 제가 놓친 부분이었습니다. 검증 로직이 잘 설계되어 있어서 문제없이 동작할 것 같습니다!감사합니다. 🙂
happy rabbit
✏ Learnings added