UPDATE
This commit is contained in:
@@ -15,6 +15,16 @@ from weather.models import WeatherForecast
|
||||
DEMO_FARM_UUID = UUID("11111111-1111-1111-1111-111111111111")
|
||||
DEMO_LATITUDE = "50.000000"
|
||||
DEMO_LONGITUDE = "50.000000"
|
||||
DEMO_FARM_BOUNDARY = {
|
||||
"type": "Polygon",
|
||||
"coordinates": [[
|
||||
[49.9995, 49.9995],
|
||||
[50.0005, 49.9995],
|
||||
[50.0005, 50.0005],
|
||||
[49.9995, 50.0005],
|
||||
[49.9995, 49.9995],
|
||||
]],
|
||||
}
|
||||
DEMO_SENSOR_PAYLOAD = {
|
||||
"sensor-7-1": {
|
||||
"soil_moisture": 42.3,
|
||||
@@ -39,7 +49,20 @@ class Command(BaseCommand):
|
||||
location, _ = SoilLocation.objects.get_or_create(
|
||||
latitude=DEMO_LATITUDE,
|
||||
longitude=DEMO_LONGITUDE,
|
||||
defaults={"farm_boundary": DEMO_FARM_BOUNDARY},
|
||||
)
|
||||
changed_fields = []
|
||||
if location.farm_boundary != DEMO_FARM_BOUNDARY:
|
||||
location.farm_boundary = DEMO_FARM_BOUNDARY
|
||||
changed_fields.append("farm_boundary")
|
||||
if not location.input_block_count:
|
||||
location.input_block_count = 1
|
||||
changed_fields.append("input_block_count")
|
||||
if not location.block_layout:
|
||||
location.set_input_block_count(1)
|
||||
changed_fields.extend(["input_block_count", "block_layout"])
|
||||
if changed_fields:
|
||||
location.save(update_fields=[*dict.fromkeys(changed_fields), "updated_at"])
|
||||
weather_forecast = (
|
||||
WeatherForecast.objects.filter(location=location)
|
||||
.order_by("-forecast_date", "-id")
|
||||
|
||||
Reference in New Issue
Block a user