활동 기반 배지 구현#165
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note
|
Seol-JY
left a comment
There was a problem hiding this comment.
p3: 이벤트 발행 위치와 관련해서, 현재 Service 레이어에서 직접 이벤트를 발행하고 있는데, 프로젝트의 레이어 구조가 UseCase → Service인 것을 감안하면 UseCase 레이어에서 발행하는 게 더 일관되지 않을까 싶습니다.
Service가 다른 도메인(배지)의 이벤트를 트리거하는 형태가 되면 의존 방향이 조금 어색해질 수 있을 것 같은데, 어떻게 생각하시나요?
| @Override | ||
| public boolean checkCondition(final User user) { | ||
| YearMonth currentMonth = YearMonth.now(); | ||
| LocalDate startDate = currentMonth.atDay(FIRST_DAY_OF_MONTH); | ||
| LocalDate endDate = currentMonth.atEndOfMonth(); | ||
| int daysInMonth = currentMonth.lengthOfMonth(); | ||
|
|
||
| long writtenDays = diaryRepository.countDistinctDateByUserAndDateBetween(user, startDate, endDate); | ||
|
|
||
| return writtenDays >= daysInMonth * MINIMUM_WRITTEN_RATIO; | ||
| } |
There was a problem hiding this comment.
p4:
YearMonth.now()를 직접 호출하고 있어서, 월말/월초 경계에서 테스트가 flaky해질 가능성이 있지 않을까요?
예를 들어 테스트가 1월 31일 23:59에 시작되었는데 실제 쿼리 시점에 2월 1일로 넘어가면, now()가 반환하는 월과 DB에 넣은 데이터의 월이 달라져서 테스트가 실패할 수 있을 것 같아요. 또한 2월(28일)과 7월(31일)에서 50% 기준 일수가 다르기 때문에 특정 월에서만 실패하는 케이스도 생길 수 있고요.
당장은 큰 문제가 없어 보여서 참고차 남깁니다..!
✨ 작업 내용
1️⃣ 활동 기반 뱃지 5종 획득 조건 구현
완벽주의 (Perfectionist): 등록된 루틴 10개 이상까마귀 (Crow): 서로 다른 루틴 카테고리 5개 이상 사용꽥꽥 (QuackQuack): 소셜 게시글 15개 이상 작성집중천재 (FocusGenius): 타이머 집중 횟수 합계 15회 이상하루일기 (DailyDiary): 해당 월의 감정일기 작성률 50% 이상 달성