UPDATE
This commit is contained in:
@@ -7,6 +7,7 @@ from rest_framework import status
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from config.integration_contract import build_integration_meta
|
||||
from config.openapi import (
|
||||
build_envelope_serializer,
|
||||
build_response,
|
||||
@@ -151,6 +152,14 @@ class PlantGrowthSimulationView(APIView):
|
||||
"status_url": f"/api/crop-simulation/growth/{task.id}/status/",
|
||||
"plant_name": serializer.validated_data["plant_name"],
|
||||
},
|
||||
"meta": build_integration_meta(
|
||||
flow_type="live_ai_inference",
|
||||
source_type="provider",
|
||||
source_service="ai_crop_simulation",
|
||||
ownership="ai",
|
||||
live=True,
|
||||
cached=False,
|
||||
),
|
||||
},
|
||||
status=status.HTTP_202_ACCEPTED,
|
||||
)
|
||||
@@ -202,7 +211,19 @@ class PlantGrowthSimulationStatusView(APIView):
|
||||
payload["error"] = str(result.result)
|
||||
|
||||
return Response(
|
||||
{"code": 200, "msg": "موفق", "data": payload},
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "موفق",
|
||||
"data": payload,
|
||||
"meta": build_integration_meta(
|
||||
flow_type="live_ai_inference",
|
||||
source_type="provider",
|
||||
source_service="ai_crop_simulation",
|
||||
ownership="ai",
|
||||
live=result.state in {"PENDING", "PROGRESS", "SUCCESS"},
|
||||
cached=False,
|
||||
),
|
||||
},
|
||||
status=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
@@ -281,7 +302,19 @@ class CurrentFarmSimulationChartView(APIView):
|
||||
)
|
||||
|
||||
return Response(
|
||||
{"code": 200, "msg": "موفق", "data": result},
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "موفق",
|
||||
"data": result,
|
||||
"meta": build_integration_meta(
|
||||
flow_type="ai_owned_derived_output",
|
||||
source_type="provider",
|
||||
source_service="ai_crop_simulation_chart",
|
||||
ownership="ai",
|
||||
live=True,
|
||||
cached=False,
|
||||
),
|
||||
},
|
||||
status=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
@@ -342,7 +375,19 @@ class HarvestPredictionView(APIView):
|
||||
)
|
||||
|
||||
return Response(
|
||||
{"code": 200, "msg": "موفق", "data": result},
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "موفق",
|
||||
"data": result,
|
||||
"meta": build_integration_meta(
|
||||
flow_type="ai_owned_derived_output",
|
||||
source_type="provider",
|
||||
source_service="ai_crop_simulation_harvest_prediction",
|
||||
ownership="ai",
|
||||
live=True,
|
||||
cached=False,
|
||||
),
|
||||
},
|
||||
status=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
@@ -388,7 +433,22 @@ class YieldPredictionView(APIView):
|
||||
{"code": 500, "msg": f"خطا در پیش بینی عملکرد: {exc}", "data": None},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
return Response({"code": 200, "msg": "موفق", "data": result}, status=status.HTTP_200_OK)
|
||||
return Response(
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "موفق",
|
||||
"data": result,
|
||||
"meta": build_integration_meta(
|
||||
flow_type="ai_owned_derived_output",
|
||||
source_type="provider",
|
||||
source_service="ai_crop_simulation_yield_prediction",
|
||||
ownership="ai",
|
||||
live=True,
|
||||
cached=False,
|
||||
),
|
||||
},
|
||||
status=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
class YieldHarvestSummaryView(APIView):
|
||||
@@ -397,7 +457,7 @@ class YieldHarvestSummaryView(APIView):
|
||||
summary="خلاصه عملکرد و برداشت",
|
||||
description=(
|
||||
"خروجی داشبورد Yield & Harvest Summary را با اتکا به داده های قطعی شبیه سازی برمی گرداند. "
|
||||
"فعلا پاسخ به صورت mock با کارت های خالی بازگردانده می شود."
|
||||
"این endpoint خروجی derived واقعی تولید می کند و پاسخ آن mock نیست."
|
||||
),
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
@@ -492,4 +552,20 @@ class YieldHarvestSummaryView(APIView):
|
||||
irrigation_recommendation=validated.get("irrigation_recommendation"),
|
||||
fertilization_recommendation=validated.get("fertilization_recommendation"),
|
||||
)
|
||||
return Response({"code": 200, "msg": "موفق", "data": payload}, status=status.HTTP_200_OK)
|
||||
return Response(
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "موفق",
|
||||
"data": payload,
|
||||
"meta": build_integration_meta(
|
||||
flow_type="ai_owned_derived_output",
|
||||
source_type="provider",
|
||||
source_service="ai_crop_simulation_yield_harvest_summary",
|
||||
ownership="ai",
|
||||
live=True,
|
||||
cached=False,
|
||||
),
|
||||
},
|
||||
status=status.HTTP_200_OK,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user