UPDATE
This commit is contained in:
+3
-11
@@ -7,7 +7,6 @@ import uuid
|
||||
import warnings
|
||||
|
||||
from django.conf import settings
|
||||
from django.apps import apps
|
||||
from django.db import transaction
|
||||
from django.utils.dateparse import parse_datetime
|
||||
from django.utils import timezone
|
||||
@@ -217,16 +216,9 @@ def reconcile_legacy_farm_plants_relation(
|
||||
farm: SensorData,
|
||||
snapshots: list[PlantCatalogSnapshot] | None = None,
|
||||
) -> None:
|
||||
snapshots = list(snapshots if snapshots is not None else get_farm_plant_snapshots(farm))
|
||||
Plant = apps.get_model("plant", "Plant")
|
||||
if Plant is None:
|
||||
return
|
||||
names = [snapshot.name for snapshot in snapshots if snapshot and snapshot.name]
|
||||
if not names:
|
||||
farm.plants.clear()
|
||||
return
|
||||
legacy_plants = list(Plant.objects.filter(name__in=names).order_by("name", "id"))
|
||||
farm.plants.set(legacy_plants)
|
||||
# AI no longer mirrors canonical plant rows locally; the legacy relation is cleared
|
||||
# so downstream services cannot accidentally read stale plant data.
|
||||
farm.plants.clear()
|
||||
|
||||
|
||||
def get_canonical_farm_record(farm_uuid: str) -> SensorData | None:
|
||||
|
||||
Reference in New Issue
Block a user