Skip to content
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 @@ -94,9 +94,9 @@ private DateRange calculateDateRange(PeriodCategory periodCategory, LocalDate to
}
LocalDate startDate = switch (periodCategory) {
case DAY -> today;
case WEEK -> today.minusWeeks(1);
case MONTH -> today.minusMonths(1);
case YEAR -> today.minusYears(1);
case WEEK -> today.minusWeeks(1).plusDays(1);
case MONTH -> today.minusMonths(1).plusDays(1);
case YEAR -> today.minusYears(1).plusDays(1);
default -> today;
};
return new DateRange(startDate, today);
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ app:
enabled: ${ENABLE_RECAPTCHA:true}
auth:
public-rate-limit:
enabled: ${ENABLE_PUBLIC_AUTH_RATE_LIMIT:}
requests: ${PUBLIC_AUTH_RATE_LIMIT_REQUESTS:}
period-seconds: ${PUBLIC_AUTH_RATE_LIMIT_PERIOD_SECONDS:}
enabled: ${ENABLE_PUBLIC_AUTH_RATE_LIMIT}
requests: ${PUBLIC_AUTH_RATE_LIMIT_REQUESTS}
period-seconds: ${PUBLIC_AUTH_RATE_LIMIT_PERIOD_SECONDS}
Comment thread
hjbin-25 marked this conversation as resolved.
reset-password:
base-url: ${RESET_PASSWORD_BASE_URL:https://clash.kr/#/reset-password?token=}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void activeTime_day_startDateIsBoundaryTodayAt06() {
}

@Test
@DisplayName("ACTIVE_TIME + WEEK: startDate는 boundary-today 기준 1주 전 06:00이다")
@DisplayName("ACTIVE_TIME + WEEK: startDate는 boundary-today 기준 6일 전 06:00이다 (정확히 7일)")
void activeTime_week_startDateIsOneWeekBeforeBoundaryTodayAt06() {
when(recordSessionRepositoryPort.findStudyTimeRankingByUserIdAndPeriod(any(), any(), any()))
.thenReturn(List.of());
Expand All @@ -123,12 +123,12 @@ void activeTime_week_startDateIsOneWeekBeforeBoundaryTodayAt06() {
.findStudyTimeRankingByUserIdAndPeriod(eq(USER_ID), start.capture(), end.capture());

assertThat(start.getValue())
.isEqualTo(expectedBoundaryToday.minusWeeks(1).atTime(BOUNDARY_HOUR, 0));
.isEqualTo(expectedBoundaryToday.minusWeeks(1).plusDays(1).atTime(BOUNDARY_HOUR, 0));
assertThat(start.getValue()).isBefore(end.getValue());
}

@Test
@DisplayName("ACTIVE_TIME + MONTH: startDate는 boundary-today 기준 1달 전 06:00이다")
@DisplayName("ACTIVE_TIME + MONTH: startDate는 boundary-today 기준 정확히 1달(+1일 조정) 06:00이다")
void activeTime_month_startDateIsOneMonthBeforeBoundaryTodayAt06() {
when(recordSessionRepositoryPort.findStudyTimeRankingByUserIdAndPeriod(any(), any(), any()))
.thenReturn(List.of());
Expand All @@ -143,11 +143,11 @@ void activeTime_month_startDateIsOneMonthBeforeBoundaryTodayAt06() {
.findStudyTimeRankingByUserIdAndPeriod(eq(USER_ID), start.capture(), end.capture());

assertThat(start.getValue())
.isEqualTo(expectedBoundaryToday.minusMonths(1).atTime(BOUNDARY_HOUR, 0));
.isEqualTo(expectedBoundaryToday.minusMonths(1).plusDays(1).atTime(BOUNDARY_HOUR, 0));
}

@Test
@DisplayName("ACTIVE_TIME + YEAR: startDate는 boundary-today 기준 1년 전 06:00이다")
@DisplayName("ACTIVE_TIME + YEAR: startDate는 boundary-today 기준 정확히 1년(+1일 조정) 06:00이다")
void activeTime_year_startDateIsOneYearBeforeBoundaryTodayAt06() {
when(recordSessionRepositoryPort.findStudyTimeRankingByUserIdAndPeriod(any(), any(), any()))
.thenReturn(List.of());
Expand All @@ -162,7 +162,7 @@ void activeTime_year_startDateIsOneYearBeforeBoundaryTodayAt06() {
.findStudyTimeRankingByUserIdAndPeriod(eq(USER_ID), start.capture(), end.capture());

assertThat(start.getValue())
.isEqualTo(expectedBoundaryToday.minusYears(1).atTime(BOUNDARY_HOUR, 0));
.isEqualTo(expectedBoundaryToday.minusYears(1).plusDays(1).atTime(BOUNDARY_HOUR, 0));
}

@Test
Expand All @@ -171,7 +171,7 @@ void activeTime_season_startIsSeasonStartDateAt06() {
LocalDate seasonStart = LocalDate.now(TEST_ZONE).minusDays(7);
LocalDate seasonEnd = LocalDate.now(TEST_ZONE).plusDays(83);
Season season = new Season(1L, null, null, "SEASON_1", seasonStart, seasonEnd);
when(seasonRepositoryPort.findCurrentSeason()).thenReturn(Optional.of(season));
when(seasonRepositoryPort.findSeasonByDate(any())).thenReturn(Optional.of(season));
when(recordSessionRepositoryPort.findStudyTimeRankingByUserIdAndPeriod(any(), any(), any()))
.thenReturn(List.of());

Expand Down Expand Up @@ -240,7 +240,7 @@ void exp_season_startIsSeasonStartDate() {
LocalDate seasonStart = LocalDate.now(TEST_ZONE).minusDays(10);
LocalDate seasonEnd = LocalDate.now(TEST_ZONE).plusDays(80);
Season season = new Season(1L, null, null, "SEASON_1", seasonStart, seasonEnd);
when(seasonRepositoryPort.findCurrentSeason()).thenReturn(Optional.of(season));
when(seasonRepositoryPort.findSeasonByDate(any())).thenReturn(Optional.of(season));
when(userExpHistoryRepositoryPort.findExpRankingByUserIdAndPeriod(any(), any(), any()))
.thenReturn(List.of());

Expand All @@ -258,7 +258,7 @@ void exp_season_startIsSeasonStartDate() {
}

@Test
@DisplayName("EXP + WEEK: startDate는 boundary-today 기준 1주 전이고, endDate는 boundary-today이다")
@DisplayName("EXP + WEEK: startDate는 boundary-today 기준 6일 전이고, endDate는 boundary-today이다 (정확히 7일)")
void exp_week_startIsOneWeekBeforeBoundaryToday() {
when(userExpHistoryRepositoryPort.findExpRankingByUserIdAndPeriod(any(), any(), any()))
.thenReturn(List.of());
Expand All @@ -272,7 +272,7 @@ void exp_week_startIsOneWeekBeforeBoundaryToday() {
verify(userExpHistoryRepositoryPort)
.findExpRankingByUserIdAndPeriod(eq(USER_ID), start.capture(), end.capture());

assertThat(start.getValue()).isEqualTo(expectedBoundaryToday.minusWeeks(1));
assertThat(start.getValue()).isEqualTo(expectedBoundaryToday.minusWeeks(1).plusDays(1));
assertThat(end.getValue()).isEqualTo(expectedBoundaryToday);
}

Expand All @@ -284,7 +284,7 @@ void gitHub_season_startIsSeasonStartDate() {
LocalDate seasonStart = LocalDate.now(TEST_ZONE).minusDays(5);
LocalDate seasonEnd = LocalDate.now(TEST_ZONE).plusDays(85);
Season season = new Season(1L, null, null, "SEASON_1", seasonStart, seasonEnd);
when(seasonRepositoryPort.findCurrentSeason()).thenReturn(Optional.of(season));
when(seasonRepositoryPort.findSeasonByDate(any())).thenReturn(Optional.of(season));
when(gitHubDailyStatsQueryPort.findGitHubRankingByUserIdAndPeriod(any(), any(), any()))
.thenReturn(List.of());

Expand Down Expand Up @@ -321,7 +321,7 @@ void gitHub_day_startAndEndAreCalendarToday() {
}

@Test
@DisplayName("GITHUB + WEEK: startDate는 캘린더 기준(00시) 오늘에서 1주 전이고, endDate는 오늘이다")
@DisplayName("GITHUB + WEEK: startDate는 캘린더 기준(00시) 오늘에서 6일 전이고, endDate는 오늘이다 (정확히 7일)")
void gitHub_week_startIsOneWeekBeforeCalendarToday() {
when(gitHubDailyStatsQueryPort.findGitHubRankingByUserIdAndPeriod(any(), any(), any()))
.thenReturn(List.of());
Expand All @@ -335,7 +335,7 @@ void gitHub_week_startIsOneWeekBeforeCalendarToday() {
verify(gitHubDailyStatsQueryPort)
.findGitHubRankingByUserIdAndPeriod(eq(USER_ID), start.capture(), end.capture());

assertThat(start.getValue()).isEqualTo(expectedCalendarToday.minusWeeks(1));
assertThat(start.getValue()).isEqualTo(expectedCalendarToday.minusWeeks(1).plusDays(1));
assertThat(end.getValue()).isEqualTo(expectedCalendarToday);
}
}
3 changes: 3 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
aws.s3.bucket=test-bucket
ENABLE_PUBLIC_AUTH_RATE_LIMIT=false
PUBLIC_AUTH_RATE_LIMIT_REQUESTS=100
PUBLIC_AUTH_RATE_LIMIT_PERIOD_SECONDS=1000
Loading