Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#35] 기상청 중기예보 API 응답 변경 대응 #36

Merged
merged 1 commit into from
Jan 2, 2025
Merged
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
8 changes: 4 additions & 4 deletions src/main/kotlin/nexters/weski/batch/ExternalWeatherService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class ExternalWeatherService(

val tmFc = baseDate.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + baseTime
// 기존 데이터 삭제
dailyWeatherRepository.deleteByDDayGreaterThanEqual(2)
dailyWeatherRepository.deleteByDDayGreaterThanEqual(4)
skiResortRepository.findAll().forEach { resort ->
val detailedAreaCode = resort.detailedAreaCode
val broadAreaCode = resort.broadAreaCode
Expand Down Expand Up @@ -252,7 +252,7 @@ class ExternalWeatherService(
return weatherList
}

for (i in 3..10) {
for (i in 5..10) {
val forecastDate = now.plusDays(i.toLong() - 1)
val dayOfWeek = forecastDate.dayOfWeek.name // 영어 요일명

Expand Down Expand Up @@ -280,7 +280,7 @@ class ExternalWeatherService(

private fun getPrecipitationChance(midLandData: JsonNode, day: Int): Int {
return when (day) {
in 3..7 -> {
in 5..7 -> {
val amChance = midLandData.get("rnSt${day}Am")?.asInt() ?: 0
val pmChance = midLandData.get("rnSt${day}Pm")?.asInt() ?: 0
maxOf(amChance, pmChance)
Expand All @@ -296,7 +296,7 @@ class ExternalWeatherService(

private fun getCondition(midLandData: JsonNode, day: Int): String {
return when (day) {
in 3..7 -> {
in 5..7 -> {
val amCondition = midLandData.get("wf${day}Am")?.asText() ?: ""
val pmCondition = midLandData.get("wf${day}Pm")?.asText() ?: ""
selectWorseCondition(amCondition, pmCondition)
Expand Down