UPDATE
This commit is contained in:
@@ -46,7 +46,13 @@ def _harvest_description(
|
||||
)
|
||||
|
||||
|
||||
def build_harvest_prediction_payload(*, farm_uuid: str, plant_name: str | None = None) -> dict[str, Any]:
|
||||
def build_harvest_prediction_payload(
|
||||
*,
|
||||
farm_uuid: str,
|
||||
plant_name: str | None = None,
|
||||
irrigation_recommendation: dict[str, Any] | None = None,
|
||||
fertilization_recommendation: dict[str, Any] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
resolved_plant_name = plant_name
|
||||
if not resolved_plant_name:
|
||||
sensor = SensorData.objects.prefetch_related("plants").filter(farm_uuid=farm_uuid).first()
|
||||
@@ -65,7 +71,11 @@ def build_harvest_prediction_payload(*, farm_uuid: str, plant_name: str | None =
|
||||
"page_size": DEFAULT_PAGE_SIZE,
|
||||
}
|
||||
)
|
||||
simulation_result, scenario_id, simulation_warning = _run_simulation(context)
|
||||
simulation_result, scenario_id, simulation_warning = _run_simulation(
|
||||
context,
|
||||
irrigation_recommendation=irrigation_recommendation,
|
||||
fertilization_recommendation=fertilization_recommendation,
|
||||
)
|
||||
daily_output = simulation_result.get("daily_output") or []
|
||||
if not daily_output:
|
||||
raise GrowthSimulationError("هیچ خروجی شبیه سازی در دسترس نیست.")
|
||||
@@ -146,5 +156,17 @@ def build_harvest_prediction_payload(*, farm_uuid: str, plant_name: str | None =
|
||||
|
||||
|
||||
class HarvestPredictionService:
|
||||
def get_harvest_prediction(self, *, farm_uuid: str, plant_name: str | None = None) -> dict[str, Any]:
|
||||
return build_harvest_prediction_payload(farm_uuid=farm_uuid, plant_name=plant_name)
|
||||
def get_harvest_prediction(
|
||||
self,
|
||||
*,
|
||||
farm_uuid: str,
|
||||
plant_name: str | None = None,
|
||||
irrigation_recommendation: dict[str, Any] | None = None,
|
||||
fertilization_recommendation: dict[str, Any] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
return build_harvest_prediction_payload(
|
||||
farm_uuid=farm_uuid,
|
||||
plant_name=plant_name,
|
||||
irrigation_recommendation=irrigation_recommendation,
|
||||
fertilization_recommendation=fertilization_recommendation,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user