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 Oct 18, 2024
1 parent 64e8169 commit 69818b1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.9 on 2024-10-18 06:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('uni_ticket', '0021_alter_task_options_alter_ticketcategorytask_options_and_more'),
]

operations = [
migrations.AddIndex(
model_name='ticketassignment',
index=models.Index(fields=['follow'], name='uni_ticket__follow_fdb55f_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'),
),
]
6 changes: 5 additions & 1 deletion uniticket/uni_ticket/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,11 @@ class TicketAssignment(TimeStampedModel):
class Meta:
unique_together = ("ticket", "office")
ordering = ["created"]
indexes = [models.Index(fields=["office_id", "follow"])]
indexes = [models.Index(fields=["office_id", "follow"]),
models.Index(fields=["follow"]),
models.Index(fields=["taken_date"]),
models.Index(fields=["taken_by"]),
]
verbose_name = _("Competenza Ticket")
verbose_name_plural = _("Competenza Ticket")

Expand Down
4 changes: 4 additions & 0 deletions uniticket/uni_ticket/views/datatables.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def fill_data(self):
if not self.fqs:
self.get_paging()

# tickets = Ticket.objects.filter(pk__in=self.fqs).select_related('created_by',
# 'compiled_by',
# 'input_module__ticket_category',
# 'closed_by')
tickets = []
for entry in self.fqs:
t = Ticket.objects.filter(pk=entry)\
Expand Down
1 change: 0 additions & 1 deletion uniticket/uni_ticket_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def test500(request):

if settings.DEBUG:
import debug_toolbar

urlpatterns += [
path('__debug__/', include(debug_toolbar.urls)),
]

0 comments on commit 69818b1

Please sign in to comment.