api response struktra ozgardi qb query kamytraildi
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from .auto import * # noqa
|
||||
from .customer import * # noqa
|
||||
from .document import * # noqa
|
||||
from .history import * # noqa
|
||||
from .movable import * # noqa
|
||||
from .quick import * # noqa
|
||||
from .real_estate import * # noqa
|
||||
|
||||
124
core/apps/evaluation/models/history.py
Normal file
124
core/apps/evaluation/models/history.py
Normal file
@@ -0,0 +1,124 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.apps.evaluation.choices.history import EvaluationEventType
|
||||
|
||||
|
||||
class AutoevaluationhistoryModel(models.Model):
|
||||
"""AutoEvaluation bo'yicha barcha harakatlar logi — faqat o'qiladi, signallar tomonidan yoziladi."""
|
||||
|
||||
auto_evaluation = models.ForeignKey(
|
||||
"evaluation.AutoEvaluationModel",
|
||||
on_delete=models.CASCADE,
|
||||
related_name="history",
|
||||
verbose_name=_("auto evaluation"),
|
||||
)
|
||||
event_type = models.CharField(
|
||||
verbose_name=_("event type"),
|
||||
max_length=50,
|
||||
choices=EvaluationEventType.choices,
|
||||
)
|
||||
|
||||
# Actor — kim bajargan (system bo'lsa actor_id=None)
|
||||
actor_id = models.BigIntegerField(
|
||||
verbose_name=_("actor id"),
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
actor_full_name = models.CharField(
|
||||
verbose_name=_("actor full name"),
|
||||
max_length=255,
|
||||
default="Tizim",
|
||||
)
|
||||
actor_role = models.CharField(
|
||||
verbose_name=_("actor role"),
|
||||
max_length=50,
|
||||
default="system",
|
||||
)
|
||||
|
||||
# Har bir event_type uchun turli struktura
|
||||
meta = models.JSONField(
|
||||
verbose_name=_("meta"),
|
||||
default=dict,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
created_at = models.DateTimeField(
|
||||
verbose_name=_("created at"),
|
||||
auto_now_add=True,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.get_event_type_display()} — AutoEval #{self.auto_evaluation_id}"
|
||||
|
||||
class Meta:
|
||||
db_table = "AutoEvaluationHistory"
|
||||
verbose_name = _("Auto Evaluation History")
|
||||
verbose_name_plural = _("Auto Evaluation Histories")
|
||||
ordering = ["created_at"]
|
||||
indexes = [
|
||||
# Asosiy query: bir baholash tarixi + sana bo'yicha tartib
|
||||
models.Index(fields=["auto_evaluation_id", "created_at"], name="auto_hist_eval_date_idx"),
|
||||
# event_type bo'yicha filter
|
||||
models.Index(fields=["event_type"], name="auto_hist_event_type_idx"),
|
||||
]
|
||||
|
||||
|
||||
class QuickevaluationhistoryModel(models.Model):
|
||||
"""QuickEvaluation bo'yicha barcha harakatlar logi — faqat o'qiladi, signallar tomonidan yoziladi."""
|
||||
|
||||
quick_evaluation = models.ForeignKey(
|
||||
"evaluation.QuickEvaluationModel",
|
||||
on_delete=models.CASCADE,
|
||||
related_name="history",
|
||||
verbose_name=_("quick evaluation"),
|
||||
)
|
||||
event_type = models.CharField(
|
||||
verbose_name=_("event type"),
|
||||
max_length=50,
|
||||
choices=EvaluationEventType.choices,
|
||||
)
|
||||
|
||||
# Actor — kim bajargan (system bo'lsa actor_id=None)
|
||||
actor_id = models.BigIntegerField(
|
||||
verbose_name=_("actor id"),
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
actor_full_name = models.CharField(
|
||||
verbose_name=_("actor full name"),
|
||||
max_length=255,
|
||||
default="Tizim",
|
||||
)
|
||||
actor_role = models.CharField(
|
||||
verbose_name=_("actor role"),
|
||||
max_length=50,
|
||||
default="system",
|
||||
)
|
||||
|
||||
# Har bir event_type uchun turli struktura
|
||||
meta = models.JSONField(
|
||||
verbose_name=_("meta"),
|
||||
default=dict,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
created_at = models.DateTimeField(
|
||||
verbose_name=_("created at"),
|
||||
auto_now_add=True,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.get_event_type_display()} — QuickEval #{self.quick_evaluation_id}"
|
||||
|
||||
class Meta:
|
||||
db_table = "QuickEvaluationHistory"
|
||||
verbose_name = _("Quick Evaluation History")
|
||||
verbose_name_plural = _("Quick Evaluation Histories")
|
||||
ordering = ["created_at"]
|
||||
indexes = [
|
||||
# Asosiy query: bir baholash tarixi + sana bo'yicha tartib
|
||||
models.Index(fields=["quick_evaluation_id", "created_at"], name="quick_hist_eval_date_idx"),
|
||||
# event_type bo'yicha filter
|
||||
models.Index(fields=["event_type"], name="quick_hist_event_type_idx"),
|
||||
]
|
||||
Reference in New Issue
Block a user