From fa3f7dbe6a10e9168b1fc16ad68014b9d62b3620 Mon Sep 17 00:00:00 2001 From: KWON Date: Mon, 27 Oct 2025 15:06:44 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B5=9C=EA=B7=BC=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=A0=80=EC=9E=A5=20=EC=83=81=ED=83=9C=EB=A5=BC=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/weather_asos.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/weather_asos.py b/lib/weather_asos.py index de28269..8e32ae3 100644 --- a/lib/weather_asos.py +++ b/lib/weather_asos.py @@ -140,23 +140,28 @@ def main(): if now.hour < 11: end_date = today - timedelta(days=2) + print(f"[INFO] 오전 11시 이전에는 전전일 데이터가 가장 최근입니다. 최종 검색일자 {end_date}") else: end_date = today - timedelta(days=1) + print(f"[INFO] 최종 검색일자 {end_date}") config_start_date = datetime.strptime(config["DATA_API"]["startDt"], "%Y%m%d").date() chunk_days = 1000 with engine.begin() as conn: + print(f"[INFO] DB 저장 최종 일자 점검") latest_date = get_latest_date_from_db(conn, table) + print(f"[INFO] 최종 저장일 : {latest_date}") if latest_date is None: start_date = config_start_date + print(f"[INFO] 최종 저장 일자가 존재하지 않아 기본 시작일자를 사용합니다. {start_date}") else: start_date = max(config_start_date, latest_date + timedelta(days=1)) + print(f"[INFO] 시작일자 : {start_date}") if start_date > end_date: - if debug: - print("[INFO] 최신 데이터가 이미 존재하거나 요청할 데이터가 없습니다.") + print("[INFO] 최신 데이터가 이미 존재하거나 요청할 데이터가 없습니다.") return start_dt = start_date.strftime("%Y%m%d") @@ -164,8 +169,7 @@ def main(): for stn_id in stn_ids: for chunk_start, chunk_end in fetch_data_range_chunks(start_dt, end_dt, chunk_days): - if debug: - print(f"[INFO] 지점 {stn_id} 데이터 요청 중: {chunk_start} ~ {chunk_end}") + print(f"[INFO] 지점 {stn_id} 데이터 요청 중: {chunk_start} ~ {chunk_end}") items = fetch_asos_data(stn_id, chunk_start, chunk_end, service_key) if items: save_items_to_db(items, conn, table, force_update, debug)