update ai insight migration for all page

This commit is contained in:
Alberto-Audrix committed 2026-09-17 10:11:14 +07:00
1 parent 07d36081ce
commit 18790ab8f6
69 files changed
+9457 -399

No files matched your search

+31 -6
View File
@@ -27,22 +27,47 @@ class IotPanel(models.Model):
class AIInsight(models.Model):
SOURCE_GENERATED = "generated"
SOURCE_CACHE = "cache"
SOURCE_LOCAL_FALLBACK = "local_fallback"
SOURCE_CHOICES = [
(SOURCE_GENERATED, "Generated"),
(SOURCE_CACHE, "Cache"),
(SOURCE_LOCAL_FALLBACK, "Local fallback"),
]
date = models.DateField()
insight_text = models.TextField()
alert = models.CharField(max_length=100)
section = models.CharField(max_length=100)
session = models.CharField(max_length=100)
alert = models.CharField(max_length=100, blank=True, default="")
cycle = models.ForeignKey(Cycle, on_delete=models.CASCADE, related_name="ai_insights")
kandang = models.ForeignKey(
"farms.Kandang",
on_delete=models.CASCADE,
related_name="ai_insights",
null=True,
blank=True,
)
topic = models.CharField(max_length=64, blank=True, default="", db_index=True)
report_type = models.CharField(max_length=32, blank=True, default="page", db_index=True)
report_period = models.CharField(max_length=64, blank=True, default="current", db_index=True)
source = models.CharField(
max_length=32,
choices=SOURCE_CHOICES,
default=SOURCE_GENERATED,
blank=True,
)
summary = models.TextField(blank=True, default="")
citations = models.TextField(blank=True, default="[]")
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "ai_insight"
ordering = ["-date"]
ordering = ["-date", "-created_at"]
constraints = [
models.UniqueConstraint(
fields=["cycle", "date", "section", "session"],
name="uniq_ai_insight_cycle_date_section_session",
fields=["cycle", "kandang", "topic", "report_type", "report_period"],
name="uniq_ai_insight_cache_scope",
)
]