From 9a9922739d793becccd34b3172168934722c7370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Sat, 21 Feb 2026 13:38:02 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[dashboard]=20=EB=82=A0=EC=94=A8=20?= =?UTF-8?q?=EC=9C=84=EC=A0=AF=20=EB=8B=A8=EA=B8=B0+=EC=A4=91=EA=B8=B0=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=B3=91=ED=95=A9=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 단기예보 기온 없는 날 중기예보 기온으로 보충 - 데이터 없는 날 '준비 중' 표시 --- app/Services/WeatherService.php | 40 +++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/app/Services/WeatherService.php b/app/Services/WeatherService.php index 81779e5a..72932b60 100644 --- a/app/Services/WeatherService.php +++ b/app/Services/WeatherService.php @@ -63,30 +63,36 @@ private function buildForecast(): array $midTa = $this->fetchMidTemperature(); $midLand = $this->fetchMidLandForecast(); - // 오늘부터 7일간 데이터 조합 + // 오늘부터 7일간 데이터 조합 (단기 + 중기 병합) $forecasts = []; for ($i = 0; $i < 7; $i++) { $date = $today->copy()->addDays($i)->format('Ymd'); - // 단기예보 데이터 우선 - if (isset($short[$date])) { - $forecasts[] = $short[$date]; - - continue; - } + $shortData = $short[$date] ?? null; // 중기예보 데이터 - $tmn = $midTa["taMin{$i}"] ?? null; - $tmx = $midTa["taMax{$i}"] ?? null; - $wf = $midLand["wf{$i}Am"] ?? ($midLand["wf{$i}"] ?? ''); + $midTmn = $midTa["taMin{$i}"] ?? null; + $midTmx = $midTa["taMax{$i}"] ?? null; + $midWf = $midLand["wf{$i}Am"] ?? ($midLand["wf{$i}"] ?? ''); - $forecasts[] = [ - 'date' => $date, - 'tmn' => $tmn, - 'tmx' => $tmx, - 'icon' => ! empty($wf) ? $this->midWeatherToIcon($wf) : null, - 'weather_text' => $wf, - ]; + if ($shortData) { + // 단기예보 우선, 기온이 없으면 중기로 보충 + $forecasts[] = [ + 'date' => $date, + 'tmn' => $shortData['tmn'] ?? $midTmn, + 'tmx' => $shortData['tmx'] ?? $midTmx, + 'icon' => $shortData['icon'] ?? (! empty($midWf) ? $this->midWeatherToIcon($midWf) : null), + 'weather_text' => $shortData['weather_text'] ?: $midWf, + ]; + } else { + $forecasts[] = [ + 'date' => $date, + 'tmn' => $midTmn, + 'tmx' => $midTmx, + 'icon' => ! empty($midWf) ? $this->midWeatherToIcon($midWf) : null, + 'weather_text' => $midWf, + ]; + } } return $forecasts;