Refactor notification scheduling with NotificationScheduleClock#56
Merged
Conversation
Test Results73 tests 73 ✅ 1s ⏱️ Results for commit fd72e75. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes notification scheduling time logic by introducing a NotificationScheduleClock component (fixed to the Asia/Seoul timezone) and refactors notification sync logic to use it, improving consistency and testability of “future schedule” checks.
Changes:
- Added
NotificationScheduleClockwithnow()andisFutureSchedule(...)helpers. - Refactored
NotificationSyncServiceto use the new clock and to centralize minute-level time normalization viaWorkScheduleTime.normalize. - Added
NotificationScheduleClockTestto validate timezone-basednow()behavior and future schedule comparisons.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/main/kotlin/com/moa/service/notification/NotificationScheduleClock.kt | New clock component for consistent Asia/Seoul time retrieval and future schedule checks. |
| src/main/kotlin/com/moa/service/notification/NotificationSyncService.kt | Refactors scheduling logic to use the clock + normalized times and simplifies work-notification filtering. |
| src/main/kotlin/com/moa/entity/notification/WorkScheduleTime.kt | Centralizes time normalization to minute precision. |
| src/test/kotlin/com/moa/service/notification/NotificationScheduleClockTest.kt | Adds unit tests covering timezone now() and future-schedule edge cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private val sut = NotificationScheduleClock() | ||
|
|
||
| @Test | ||
| fun `now 는 Asia_Seoul timezone 기준 현재 시각을 반환한다`() { |
Comment on lines
+10
to
+14
| class NotificationScheduleClock { | ||
| fun now(): LocalDateTime = LocalDateTime.now(ZoneId.of("Asia/Seoul")) | ||
|
|
||
| fun isFutureSchedule(date: LocalDate, time: LocalTime, now: LocalDateTime = now()): Boolean = | ||
| date.atTime(time).isAfter(now) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new
NotificationScheduleClockcomponent to centralize and standardize time-related logic for scheduling notifications, ensuring consistent timezone handling and future schedule checks. The changes also improve code readability and testability by refactoring direct time calculations into reusable methods. Additionally, the pull request includes tests for the new clock component and some minor code cleanups.Core improvements to scheduling and time handling:
NotificationScheduleClockcomponent to encapsulate current time retrieval (using the "Asia/Seoul" timezone) and provide a reusableisFutureSchedulemethod for checking if a schedule is in the future.NotificationSyncServiceto useNotificationScheduleClockfor all time-related logic, replacing direct calls toLocalDateTime.nowand manual timezone handling. [1] [2] [3] [4]Normalization and code cleanup:
WorkScheduleTime.normalize, replacing inlineLocalTime.of(hour, minute)usages with a dedicated method for clarity and consistency. [1] [2] [3]workNotificationTypeslist.Testing:
NotificationScheduleClockTestto verify correct behavior of the clock component, including timezone handling and future schedule determination.