Skip to content

Commit

Permalink
[feat] #8 체크리스트 중 빈도에 해당하는 요소의 정확도를 측정하는 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuKwanKon committed Dec 29, 2023
1 parent 3e7712b commit e9e952d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ private List<PostSearchResponseDto> createPostSearchResponseDto(Page<PostSearchD

private int getAccuracy(PostCheckList postCheckList, CheckList checkList) {
int count = 0;
count = postCheckList.getCleanType().equals(checkList.getCleanType()) ? count + 1 : count;
count = postCheckList.getDrinkType().equals(checkList.getDrinkType()) ? count + 1 : count;
count = postCheckList.getHomeType().equals(checkList.getHomeType()) ? count + 1 : count;
count += getRateForFrequencyElement(postCheckList.getCleanType().getCode(), checkList.getCleanType().getCode());
count += getRateForFrequencyElement(postCheckList.getDrinkType().getCode(), checkList.getDrinkType().getCode());
count += getRateForFrequencyElement(postCheckList.getHomeType().getCode(), checkList.getHomeType().getCode());
count = postCheckList.getLifePatterType().equals(checkList.getLifePatterType()) ? count + 1 : count;
count = postCheckList.getNoiseType().equals(checkList.getNoiseType()) ? count + 1 : count;
count = postCheckList.getSleepType().equals(checkList.getSleepType()) ? count + 1 : count;
return (int) (count / 6) * 100;
}

private int getRateForFrequencyElement(String firstEnumCode, String secondEnumCode) {
return 1 - Math.abs(Integer.parseInt(firstEnumCode) - Integer.parseInt(secondEnumCode));
}

private int getRemainDate(LocalDate endDate) {
return (int) endDate.until(LocalDate.now(), ChronoUnit.DAYS);
}
Expand Down

0 comments on commit e9e952d

Please sign in to comment.