fix(push-notification-list): 푸시 알림 조회 기간 타임존 기준을 로컬 1주로 통일한다
This commit is contained in:
19
docs/20260313_푸시알림조회기간타임존정합성수정.md
Normal file
19
docs/20260313_푸시알림조회기간타임존정합성수정.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
## 작업 개요
|
||||||
|
|
||||||
|
- [x] `PushNotificationService`의 1주 조회 시작 시각 계산 기준을 저장 시각(`BaseEntity.createdAt`)과 동일한 시스템 기본 타임존으로 통일한다.
|
||||||
|
- [x] `getNotificationList` 및 `getAvailableCategories`가 동일한 1주일 범위를 유지하는지 확인한다.
|
||||||
|
- [x] 관련 import/함수명을 정리해 코드 가독성과 의도를 명확히 한다.
|
||||||
|
- [x] 변경 파일 진단과 Gradle 검증(`test`, `build`)을 수행하고 결과를 기록한다.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 검증 기록
|
||||||
|
|
||||||
|
### 1차 구현
|
||||||
|
|
||||||
|
- 무엇을: `PushNotificationService`의 조회 기간 계산을 UTC 기준에서 시스템 기본 타임존 기준으로 변경.
|
||||||
|
- 왜: `createdAt` 저장 시각이 시스템 기본 타임존(`LocalDateTime.now()`)이므로 조회 기준만 UTC를 사용하면 서버 타임존이 UTC가 아닐 때 실제 조회 기간이 7일과 어긋날 수 있음.
|
||||||
|
- 어떻게:
|
||||||
|
- `lsp_diagnostics` 실행: `.kt` 확장자용 LSP 서버 미설정으로 도구 진단 불가(환경 제약 확인).
|
||||||
|
- `./gradlew test` 실행: 성공(BUILD SUCCESSFUL).
|
||||||
|
- `./gradlew build` 실행: 성공(BUILD SUCCESSFUL).
|
||||||
@@ -17,7 +17,6 @@ import org.springframework.data.repository.findByIdOrNull
|
|||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import org.springframework.transaction.annotation.Transactional
|
import org.springframework.transaction.annotation.Transactional
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.ZoneOffset
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@@ -82,7 +81,7 @@ class PushNotificationService(
|
|||||||
): GetPushNotificationListResponse {
|
): GetPushNotificationListResponse {
|
||||||
val parsedCategory = parseCategory(category)
|
val parsedCategory = parseCategory(category)
|
||||||
val languageCode = langContext.lang.code
|
val languageCode = langContext.lang.code
|
||||||
val fromDateTime = oneMonthAgoUtc()
|
val fromDateTime = oneWeekAgo()
|
||||||
|
|
||||||
val totalCount = pushNotificationListRepository.getNotificationCount(
|
val totalCount = pushNotificationListRepository.getNotificationCount(
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
@@ -110,7 +109,7 @@ class PushNotificationService(
|
|||||||
val localizedCategories = pushNotificationListRepository.getAvailableCategories(
|
val localizedCategories = pushNotificationListRepository.getAvailableCategories(
|
||||||
memberId = member.id!!,
|
memberId = member.id!!,
|
||||||
languageCode = lang.code,
|
languageCode = lang.code,
|
||||||
fromDateTime = oneMonthAgoUtc()
|
fromDateTime = oneWeekAgo()
|
||||||
).map { category ->
|
).map { category ->
|
||||||
messageSource.getMessage("push.notification.category.${category.code}", lang) ?: category.code
|
messageSource.getMessage("push.notification.category.${category.code}", lang) ?: category.code
|
||||||
}
|
}
|
||||||
@@ -150,8 +149,8 @@ class PushNotificationService(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun oneMonthAgoUtc(): LocalDateTime {
|
private fun oneWeekAgo(): LocalDateTime {
|
||||||
return LocalDateTime.now(ZoneOffset.UTC).minusMonths(1)
|
return LocalDateTime.now().minusWeeks(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resolveCategory(fcmEvent: FcmEvent): PushNotificationCategory? {
|
private fun resolveCategory(fcmEvent: FcmEvent): PushNotificationCategory? {
|
||||||
|
|||||||
Reference in New Issue
Block a user