UPDATE
This commit is contained in:
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from datetime import date, timedelta
|
||||
from typing import Any
|
||||
|
||||
from farm_data.models import SensorData
|
||||
from farm_data.services import get_canonical_farm_record, get_runtime_plant_for_farm
|
||||
from plant.gdd import resolve_growth_profile
|
||||
|
||||
from .growth_simulation import (
|
||||
@@ -55,10 +55,10 @@ def build_harvest_prediction_payload(
|
||||
) -> 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()
|
||||
if sensor is None:
|
||||
farm = get_canonical_farm_record(farm_uuid)
|
||||
if farm is None:
|
||||
raise GrowthSimulationError("مزرعه پیدا نشد.")
|
||||
plant = sensor.plants.first()
|
||||
plant = get_runtime_plant_for_farm(farm)
|
||||
if plant is None:
|
||||
raise GrowthSimulationError("گیاهی برای مزرعه انتخاب شده پیدا نشد.")
|
||||
resolved_plant_name = plant.name
|
||||
|
||||
Reference in New Issue
Block a user