Skip to content

Commit

Permalink
fix: 처음부터 마지막 날일경우 데이터가 오지 않는 버그 수정 (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjy1368 authored Aug 10, 2021
1 parent ba60b2b commit b4d848d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ private List<CommentStat> getStatByNoneDaily(LocalDateTime startDate, LocalDateT
}
noneMonthCommentStats.add(new CommentStat(localDate.toString(), DEFAULT_COMMENT_COUNT));
localDate = localDate.plusDays(1L);

if (localDate.equals(end) && !isExistDailyStat(commentStats, localDate)) {
noneMonthCommentStats.add(new CommentStat(localDate.toString(), DEFAULT_COMMENT_COUNT));
}
}
if (!isExistDailyStat(commentStats, localDate)) {
noneMonthCommentStats.add(new CommentStat(localDate.toString(), DEFAULT_COMMENT_COUNT));
}
return noneMonthCommentStats;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ private List<CommentStat> getStatByNoneMonth(LocalDateTime startDate, LocalDateT
}
noneMonthCommentStats.add(new CommentStat(yearMonth.toString(), DEFAULT_COMMENT_COUNT));
yearMonth = yearMonth.plusMonths(1L);

if (yearMonth.equals(endYearMonth) && !isExistMonthStat(commentStats, yearMonth)) {
noneMonthCommentStats.add(new CommentStat(yearMonth.toString(), DEFAULT_COMMENT_COUNT));
}
}

if (!isExistMonthStat(commentStats, yearMonth)) {
noneMonthCommentStats.add(new CommentStat(yearMonth.toString(), DEFAULT_COMMENT_COUNT));
}
return noneMonthCommentStats;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ void stat_daily() {
.hasSize((int) ChronoUnit.DAYS.between(startDate, endDate) + 1);
}

@DisplayName("특정 프로젝트의 일별 댓글 통계를 구한다. (시작 날짜 = 종료 날짜)")
@Test
void stat_daily_same_date() {
LocalDate localDate = LocalDate.now().minusYears(10L);
CommentStatRequest request = new CommentStatRequest("DAILY", project.getSecretKey(),
localDate, localDate);
CommentStatResponse commentStatResponse = commentService.giveStat(request);
assertThat(commentStatResponse.getCommentStats())
.hasSize(1);
}

@DisplayName("특정 프로젝트의 월별 댓글 통계를 구한다.")
@Test
void stat_monthly() {
Expand All @@ -323,8 +334,17 @@ void stat_monthly() {
CommentStatRequest request = new CommentStatRequest("MONTHLY", project.getSecretKey(),
startDate, endDate);
CommentStatResponse commentStatResponse = commentService.giveStat(request);
assertThat(commentStatResponse.getCommentStats())
.hasSize((int) ChronoUnit.MONTHS.between(startDate, endDate) + 1);
assertThat(commentStatResponse.getCommentStats()).hasSize((int) ChronoUnit.MONTHS.between(startDate, endDate) + 1);
}

@DisplayName("특정 프로젝트의 월별 댓글 통계를 구한다. (시작 날짜 = 종료 날짜)")
@Test
void stat_monthly_same_date() {
LocalDate localDate = LocalDate.now().minusYears(10L);
CommentStatRequest request = new CommentStatRequest("MONTHLY", project.getSecretKey(),
localDate, localDate);
CommentStatResponse commentStatResponse = commentService.giveStat(request);
assertThat(commentStatResponse.getCommentStats()).hasSize(1);
}

@DisplayName("소셜 로그인 유저가 댓글을 수정한다.")
Expand Down

0 comments on commit b4d848d

Please sign in to comment.