Merged
Conversation
This should avoid issues on the fetch_or_create methods accessing position [0] in an empty list of the given activity type respose.
adding the push thi/fligh/spray flags to the setup of the FC jobs
…rror when connection lost (#14) * Handle error on no internet * Handle empty json response from FC * Add a safer check on empty graph list * Add farm name and parcel to the obs title and desc * Eagerly fetch parcels from FC
…ur instead of just rain
There was a problem hiding this comment.
Pull request overview
Adds new API v1 endpoints to serve hourly full-day timelines (including past hours) backed by Open-Meteo, and updates FarmCalendar integration to attach farm/parcel metadata when scheduling and posting observations.
Changes:
- Added
GET /api/v1/forecast/hourly/andGET /api/v1/forecast/hourly/spray/endpoints for hourly weather + hourly spray suitability. - Extended
OpenMeteoClientwith a Forecast-API-backedget_hourly_forecast()and shared fetch/error handling. - Updated FarmCalendar location fetching + scheduler/job posting to carry farm/parcel identifiers instead of raw lat/lon.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
src/api/api_v1/endpoints/forecast.py |
New hourly forecast + spray endpoints using Open-Meteo hourly data. |
src/external_services/openmeteo.py |
Adds hourly forecast method and shared HTTP fetch helper. |
src/api/api_v1/api.py |
Registers the new /forecast routes in API v1. |
src/openagri_services/farmcalendar_service.py |
Enriches locations with farm/parcel metadata and includes it in posted observations. |
src/scheduler.py |
Switches scheduled FarmCalendar pushes to use enriched location info and adjusts refresh scheduling. |
src/core/app.py |
Only fetches FarmCalendar activity types when corresponding push flags are enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces two new hourly forecast endpoints backed by Open-Meteo, providing full-day timelines (including past hours) plus multiple forecast days.
Summary of Changes
New endpoint:
GET /api/v1/forecast/hourly/HourlyResponsewith 1‑hour resolution from 00:00 of today through 23:00 of the last forecast day.WeatherClientFactoryto query Open-Meteo and wraps results with location and source metadata.New endpoint:
GET /api/v1/forecast/hourly/spray/SprayForecastResponseentries, one per hour, for today + nextdays.calculate_wet_bulb).optimal,marginal, orunsuitableusingevaluate_spray_conditions.SprayStatusenums to strings for a JSON‑friendlydetailed_statuspayload.locationandsource="open-meteo"metadata.Notes
daysenforces1–16days (inclusive).502with a clear error message if Open-Meteo data cannot be retrieved.