Avoid repeated runway history copies
This commit is contained in:
@@ -216,6 +216,7 @@ def _append_latest_amsc_runway_history(
|
|||||||
raw_payload: dict[str, Any],
|
raw_payload: dict[str, Any],
|
||||||
*,
|
*,
|
||||||
persist: bool = True,
|
persist: bool = True,
|
||||||
|
copy_history: bool = True,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
runway_obs = raw_payload.get("runway_obs")
|
runway_obs = raw_payload.get("runway_obs")
|
||||||
if not isinstance(runway_obs, dict):
|
if not isinstance(runway_obs, dict):
|
||||||
@@ -235,7 +236,7 @@ def _append_latest_amsc_runway_history(
|
|||||||
history = payload.get("runway_plate_history")
|
history = payload.get("runway_plate_history")
|
||||||
if not isinstance(history, dict):
|
if not isinstance(history, dict):
|
||||||
history = {}
|
history = {}
|
||||||
else:
|
elif copy_history:
|
||||||
history = deepcopy(history)
|
history = deepcopy(history)
|
||||||
|
|
||||||
use_fahrenheit = "F" in str(payload.get("temp_symbol") or "").upper()
|
use_fahrenheit = "F" in str(payload.get("temp_symbol") or "").upper()
|
||||||
@@ -320,6 +321,8 @@ def _append_amsc_runway_history_from_raw_store(
|
|||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.debug("latest AMSC raw history overlay skipped city={}: {}", city, exc)
|
logger.debug("latest AMSC raw history overlay skipped city={}: {}", city, exc)
|
||||||
return False
|
return False
|
||||||
|
existing_history = payload.get("runway_plate_history")
|
||||||
|
payload["runway_plate_history"] = deepcopy(existing_history) if isinstance(existing_history, dict) else {}
|
||||||
changed = False
|
changed = False
|
||||||
for row in rows if isinstance(rows, list) else []:
|
for row in rows if isinstance(rows, list) else []:
|
||||||
if not isinstance(row, dict):
|
if not isinstance(row, dict):
|
||||||
@@ -334,6 +337,7 @@ def _append_amsc_runway_history_from_raw_store(
|
|||||||
row,
|
row,
|
||||||
raw_payload,
|
raw_payload,
|
||||||
persist=False,
|
persist=False,
|
||||||
|
copy_history=False,
|
||||||
) or changed
|
) or changed
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user