feat(src/tickets): add database indexes for performance
Improve query speed on Ticket, TicketComment, and TicketPriority by indexing fields used in frequent filters and ordering.
This commit is contained in:
1 file changed
+10
@@ -20,6 +20,9 @@ class TicketPriority(models.Model):
|
|||||||
db_table = "ticket_priorities"
|
db_table = "ticket_priorities"
|
||||||
verbose_name = "Ticket Priority"
|
verbose_name = "Ticket Priority"
|
||||||
verbose_name_plural = "Ticket Priorities"
|
verbose_name_plural = "Ticket Priorities"
|
||||||
|
indexes = [
|
||||||
|
models.Index(fields=["name"]),
|
||||||
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
@@ -103,6 +106,12 @@ class Ticket(models.Model):
|
|||||||
models.Index(fields=["due_date"]),
|
models.Index(fields=["due_date"]),
|
||||||
models.Index(fields=["priority"]),
|
models.Index(fields=["priority"]),
|
||||||
models.Index(fields=["created_by"]),
|
models.Index(fields=["created_by"]),
|
||||||
|
models.Index(fields=["epic"]),
|
||||||
|
models.Index(fields=["name"]),
|
||||||
|
models.Index(fields=["start_date"]),
|
||||||
|
models.Index(fields=["project", "name"]),
|
||||||
|
models.Index(fields=["project", "start_date", "due_date"]),
|
||||||
|
models.Index(fields=["due_date", "status"]),
|
||||||
]
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@@ -190,6 +199,7 @@ class TicketComment(models.Model):
|
|||||||
verbose_name_plural = "Ticket Comments"
|
verbose_name_plural = "Ticket Comments"
|
||||||
indexes = [
|
indexes = [
|
||||||
models.Index(fields=["ticket", "created_at"]),
|
models.Index(fields=["ticket", "created_at"]),
|
||||||
|
models.Index(fields=["user"]),
|
||||||
]
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
Reference in new issue
Block a user