Skip to content

Refactor notification scheduling with NotificationScheduleClock#56

Merged
subsub97 merged 1 commit into
mainfrom
refactor/notification-sync-clock
May 26, 2026
Merged

Refactor notification scheduling with NotificationScheduleClock#56
subsub97 merged 1 commit into
mainfrom
refactor/notification-sync-clock

Conversation

@subsub97

Copy link
Copy Markdown
Collaborator

This pull request introduces a new NotificationScheduleClock component 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:

  • Introduced the NotificationScheduleClock component to encapsulate current time retrieval (using the "Asia/Seoul" timezone) and provide a reusable isFutureSchedule method for checking if a schedule is in the future.
  • Refactored NotificationSyncService to use NotificationScheduleClock for all time-related logic, replacing direct calls to LocalDateTime.now and manual timezone handling. [1] [2] [3] [4]

Normalization and code cleanup:

  • Centralized time normalization logic in WorkScheduleTime.normalize, replacing inline LocalTime.of(hour, minute) usages with a dedicated method for clarity and consistency. [1] [2] [3]
  • Simplified filtering logic for pending work notifications by using a predefined workNotificationTypes list.

Testing:

  • Added a new test class NotificationScheduleClockTest to verify correct behavior of the clock component, including timezone handling and future schedule determination.

Copilot AI review requested due to automatic review settings May 26, 2026 14:05
@github-actions

Copy link
Copy Markdown

Test Results

73 tests   73 ✅  1s ⏱️
11 suites   0 💤
11 files     0 ❌

Results for commit fd72e75.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 NotificationScheduleClock with now() and isFutureSchedule(...) helpers.
  • Refactored NotificationSyncService to use the new clock and to centralize minute-level time normalization via WorkScheduleTime.normalize.
  • Added NotificationScheduleClockTest to validate timezone-based now() 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)
@subsub97
subsub97 merged commit e17cad0 into main May 26, 2026
4 checks passed
@subsub97
subsub97 deleted the refactor/notification-sync-clock branch May 26, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants