UPDATE
This commit is contained in:
@@ -6,7 +6,7 @@ import json
|
||||
import logging
|
||||
|
||||
from irrigation.evapotranspiration import calculate_forecast_water_needs, resolve_crop_profile, resolve_kc
|
||||
from sensor_data.models import SensorData
|
||||
from farm_data.models import SensorData
|
||||
from rag.api_provider import get_chat_client
|
||||
from rag.chat import build_rag_context, _load_service_tone
|
||||
from rag.config import load_rag_config, RAGConfig, get_service_config
|
||||
@@ -77,7 +77,7 @@ def get_irrigation_recommendation(
|
||||
|
||||
user_query = query or "توصیه آبیاری برای مزرعه من چیست؟"
|
||||
|
||||
sensor = SensorData.objects.select_related("location").prefetch_related("plants").filter(uuid_sensor=sensor_uuid).first()
|
||||
sensor = SensorData.objects.select_related("center_location").prefetch_related("plants").filter(farm_uuid=sensor_uuid).first()
|
||||
plant = None
|
||||
if sensor is not None and plant_name:
|
||||
plant = sensor.plants.filter(name=plant_name).first()
|
||||
@@ -89,7 +89,7 @@ def get_irrigation_recommendation(
|
||||
daily_water_needs = []
|
||||
if sensor is not None:
|
||||
forecasts = list(
|
||||
WeatherForecast.objects.filter(location=sensor.location, forecast_date__isnull=False)
|
||||
WeatherForecast.objects.filter(location=sensor.center_location, forecast_date__isnull=False)
|
||||
.order_by("forecast_date")[:7]
|
||||
)
|
||||
efficiency_percent = None
|
||||
@@ -100,7 +100,7 @@ def get_irrigation_recommendation(
|
||||
efficiency_percent = getattr(method, "water_efficiency_percent", None) if method else None
|
||||
daily_water_needs = calculate_forecast_water_needs(
|
||||
forecasts=forecasts,
|
||||
latitude_deg=float(sensor.location.latitude),
|
||||
latitude_deg=float(sensor.center_location.latitude),
|
||||
crop_profile=crop_profile,
|
||||
growth_stage=growth_stage,
|
||||
irrigation_efficiency_percent=efficiency_percent,
|
||||
|
||||
Reference in New Issue
Block a user