This commit is contained in:
2026-04-10 16:12:51 +03:30
parent 20fd3842b6
commit 883573004c
143 changed files with 1380 additions and 2332 deletions
+32
View File
@@ -0,0 +1,32 @@
import uuid as uuid_lib
from django.db import models
from farm_hub.models import FarmHub
class YieldHarvestPredictionLog(models.Model):
uuid = models.UUIDField(default=uuid_lib.uuid4, unique=True, editable=False, db_index=True)
farm = models.ForeignKey(
FarmHub,
on_delete=models.CASCADE,
related_name="yield_harvest_predictions",
null=True,
blank=True,
)
yield_stats = models.CharField(max_length=64, blank=True, default="")
yield_chip_text = models.CharField(max_length=32, blank=True, default="")
harvest_date = models.DateField(null=True, blank=True)
days_until_harvest = models.IntegerField(null=True, blank=True)
optimal_window_start = models.DateField(null=True, blank=True)
optimal_window_end = models.DateField(null=True, blank=True)
chart_data = models.JSONField(default=dict, blank=True)
fetched_at = models.DateTimeField(auto_now_add=True)
class Meta:
db_table = "yield_harvest_prediction_logs"
ordering = ["-fetched_at"]
def __str__(self):
farm_label = str(self.farm_id) if self.farm_id else "no-farm"
return f"{farm_label}{self.yield_stats} harvest:{self.harvest_date}"