Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a0c45d9fc0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| nearest_station = min( | ||
| stations, | ||
| key=lambda station: haversine_distance(lat, lng, station["lat"], station["lng"]) | ||
| ) |
There was a problem hiding this comment.
Fall back when nearest AEMET station is out of range
With AEMET_API_KEY configured, this path always picks the mathematically nearest AEMET station and immediately uses it, but there is no maximum-distance check before returning. For coordinates outside AEMET coverage (or far from any station), /api/conditions will return weather from a distant station instead of the Open-Meteo fallback, producing incorrect flight recommendations for those locations.
Useful? React with 👍 / 👎.
| wind_direction = to_float(observation.get("dv"), 0.0) | ||
| visibility_km = to_float(observation.get("vis"), 10000.0) / 1000.0 | ||
|
|
||
| weather_code = 63 if observation.get("prec") not in (None, "Ip", "") else 1 |
There was a problem hiding this comment.
Parse zero precipitation as non-rain
This condition marks weather as rainy whenever prec is any non-empty value, so numeric zero values like 0/0.0 are treated as rain and mapped to code 63. In those cases, dry observations are scored and recommended as worse-than-actual conditions, which skews flight_score and recommendation; precipitation should be parsed numerically and only considered rain when it is greater than zero (while still handling Ip).
Useful? React with 👍 / 👎.
Motivation
AEMET_API_KEY.package-lock.jsonand document new env usage in theREADME.md.Description
backend/server.pyincludingAEMET_API_KEY,AEMET_BASE_URL, a 6‑hour stations cache and helper functionsfetch_aemet_dataset,get_aemet_stations,parse_aemet_coordinate,parse_aemet_observation, andparse_aemet_weather_descriptionto convert AEMET data into the app'sFlightConditionmodel./api/conditionshandler to try AEMET observations first (whenAEMET_API_KEYis configured) and fall back to the existing Open‑Meteo call if AEMET is unavailable or fails, preserving existing scoring logic viacompute_flight_score.to_float), and minor utility imports (timedelta,urlencode) to support the new flows.README.mdto document the recommendedAEMET_API_KEYenvironment variable and noted the Open‑Meteo fallback, and added the generatedfrontend/package-lock.jsonto lock frontend dependency versions.Testing
Codex Task