update sync data from site dashboard and testing closing cycles

This commit is contained in:
Alberto-Audrix committed 2026-09-15 16:52:41 +07:00
1 parent 36639d8c38
commit f49e72592c
42 files changed
+1966 -688

No files matched your search

+27
View File
@@ -68,12 +68,24 @@ class Kandang(models.Model):
kandang_name = models.CharField(max_length=30)
feed_in_button_urls = models.JSONField(default=list, blank=True)
site = models.ForeignKey(Site, on_delete=models.CASCADE, related_name="kandangs")
source_kandang_id = models.BigIntegerField(
null=True,
blank=True,
help_text="kandang_id on the farm-location dashboard-cpsp deployment",
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "kandang"
ordering = ["kandang_name"]
constraints = [
models.UniqueConstraint(
fields=["site", "source_kandang_id"],
condition=models.Q(source_kandang_id__isnull=False),
name="uniq_kandang_site_source",
),
]
def __str__(self) -> str:
return self.kandang_name
@@ -87,12 +99,24 @@ class Flock(models.Model):
on_delete=models.CASCADE,
related_name="flocks",
)
source_flock_id = models.BigIntegerField(
null=True,
blank=True,
help_text="flock_id on the farm-location dashboard-cpsp deployment",
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "flock"
ordering = ["flock_name"]
constraints = [
models.UniqueConstraint(
fields=["kandang", "source_flock_id"],
condition=models.Q(source_flock_id__isnull=False),
name="uniq_flock_kandang_source",
),
]
def __str__(self) -> str:
return self.flock_name
@@ -116,6 +140,9 @@ class Cycle(models.Model):
doc_in_count = models.IntegerField()
feed_initial_balance = models.IntegerField(default=0)
feed_initial_balance_date = models.DateField(null=True, blank=True)
feed_initial_balance_iot = models.IntegerField(null=True, blank=True)
feed_initial_balance_accuracy = models.FloatField(null=True, blank=True)
feed_initial_balance_sync_error = models.TextField(null=True, blank=True)
status = models.CharField(
max_length=30, choices=STATUS_CHOICES, default=STATUS_ACTIVE, db_index=True
)