UPDATE
This commit is contained in:
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from statistics import mean
|
||||
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 .growth_simulation import GrowthSimulationError, _run_simulation, _safe_float, build_growth_context
|
||||
|
||||
@@ -94,11 +94,11 @@ class WaterStressSimulationService:
|
||||
if plant_name:
|
||||
return 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("Farm not found.")
|
||||
|
||||
plant = sensor.plants.first()
|
||||
plant = get_runtime_plant_for_farm(farm)
|
||||
if plant is None:
|
||||
raise GrowthSimulationError("Plant not found for the selected farm.")
|
||||
return plant.name
|
||||
|
||||
Reference in New Issue
Block a user