diff --git a/src/main/java/com/process/clash/application/ranking/service/GetRankingService.java b/src/main/java/com/process/clash/application/ranking/service/GetRankingService.java index 3ee6b13c4..e1bf88237 100644 --- a/src/main/java/com/process/clash/application/ranking/service/GetRankingService.java +++ b/src/main/java/com/process/clash/application/ranking/service/GetRankingService.java @@ -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); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1941ec26c..c5a60cf6d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -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} reset-password: base-url: ${RESET_PASSWORD_BASE_URL:https://clash.kr/#/reset-password?token=} diff --git a/src/test/java/com/process/clash/application/ranking/service/GetRankingServiceTest.java b/src/test/java/com/process/clash/application/ranking/service/GetRankingServiceTest.java index 3647d9ccb..9ead310eb 100644 --- a/src/test/java/com/process/clash/application/ranking/service/GetRankingServiceTest.java +++ b/src/test/java/com/process/clash/application/ranking/service/GetRankingServiceTest.java @@ -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()); @@ -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()); @@ -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()); @@ -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 @@ -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()); @@ -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()); @@ -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()); @@ -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); } @@ -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()); @@ -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()); @@ -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); } } diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 7da3d8707..e4d0bc58a 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -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