최근 데이터 저장 상태를 확인할 수 있는 메시지 출력
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user