Skip to content

Commit

Permalink
fix: db indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Nov 14, 2024
1 parent 990d4a1 commit 010ee5a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 4.2.16 on 2024-11-14 09:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('uni_ticket', '0023_remove_ticketassignment_uni_ticket__office__f42ab9_idx_and_more'),
]

operations = [
migrations.AddIndex(
model_name='ticket',
index=models.Index(fields=['is_closed'], name='uni_ticket__is_clos_8d6d44_idx'),
),
migrations.AddIndex(
model_name='ticket',
index=models.Index(fields=['priority'], name='uni_ticket__priorit_88a7f5_idx'),
),
migrations.AddIndex(
model_name='ticket',
index=models.Index(fields=['created'], name='uni_ticket__created_bb296d_idx'),
),
migrations.AddIndex(
model_name='ticket',
index=models.Index(fields=['priority', 'created'], name='uni_ticket__priorit_0666dd_idx'),
),
migrations.AddIndex(
model_name='ticketassignment',
index=models.Index(fields=['office', 'follow'], name='uni_ticket__office__f42ab9_idx'),
),
migrations.AddIndex(
model_name='ticketassignment',
index=models.Index(fields=['taken_date'], name='uni_ticket__taken_d_7d4fc6_idx'),
),
migrations.AddIndex(
model_name='ticketassignment',
index=models.Index(fields=['taken_by'], name='uni_ticket__taken_b_8d7e69_idx'),
),
migrations.AddIndex(
model_name='ticketassignment',
index=models.Index(fields=['ticket', 'office'], name='uni_ticket__ticket__c50811_idx'),
),
]
12 changes: 12 additions & 0 deletions uniticket/uni_ticket/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,12 @@ class Meta:
]
verbose_name = _("Ticket")
verbose_name_plural = _("Ticket")
indexes = [
models.Index(fields=["is_closed"]),
models.Index(fields=["priority"]),
models.Index(fields=["created"]),
models.Index(fields=["priority", "created"]),
]

@property
def taken_date(self):
Expand Down Expand Up @@ -1186,6 +1192,12 @@ class TicketAssignment(TimeStampedModel):
class Meta:
unique_together = ("ticket", "office")
ordering = ["created"]
indexes = [
models.Index(fields=["office", "follow"]),
models.Index(fields=["taken_date"]),
models.Index(fields=["taken_by"]),
models.Index(fields=["ticket", "office"]),
]
# indexes = [models.Index(fields=["office_id", "follow"])]
verbose_name = _("Competenza Ticket")
verbose_name_plural = _("Competenza Ticket")
Expand Down

0 comments on commit 010ee5a

Please sign in to comment.