feat(src/projects): add indexes on Project.name and Project.created_at
Add database indexes for name and created_at fields to speed up filtering and ordering queries.
This commit is contained in:
1 file changed
+6
@@ -31,6 +31,8 @@ class Project(models.Model):
|
||||
indexes = [
|
||||
models.Index(fields=["pinned_date"]),
|
||||
models.Index(fields=["start_date", "end_date"]),
|
||||
models.Index(fields=["name"]),
|
||||
models.Index(fields=["created_at"]),
|
||||
]
|
||||
|
||||
def pin(self):
|
||||
@@ -124,6 +126,10 @@ class AutomationRule(models.Model):
|
||||
verbose_name = "Automation Rule"
|
||||
verbose_name_plural = "Automation Rules"
|
||||
ordering = ["-created_at"]
|
||||
indexes = [
|
||||
models.Index(fields=["project", "is_active", "trigger_event"]),
|
||||
models.Index(fields=["created_at"]),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f"[{self.project.ticket_prefix}] {self.name}"
|
||||
|
||||
Reference in new issue
Block a user