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 73944cf
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 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
15 changes: 10 additions & 5 deletions uniticket/uni_ticket/views/datatables.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,19 @@ def fill_data(self):
if not self.fqs:
self.get_paging()

tickets = []
for entry in self.fqs:
t = Ticket.objects.filter(pk=entry)\
.select_related('created_by',
tickets = Ticket.objects.filter(pk__in=self.fqs).select_related('created_by',
'compiled_by',
'input_module__ticket_category',
'closed_by')
tickets.append(t.first())
# tickets = []
# print(self.fqs)
# for entry in self.fqs:
# t = Ticket.objects.filter(pk=entry)\
# .select_related('created_by',
# 'compiled_by',
# 'input_module__ticket_category',
# 'closed_by')
# tickets.append(t.first())

for r in tickets:
cleaned_data = []
Expand Down
11 changes: 6 additions & 5 deletions uniticket/uni_ticket_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ def test500(request):
urlpatterns += (path("", include(accounts.urls, "accounts")),)

if settings.DEBUG:
import debug_toolbar

urlpatterns += [
path('__debug__/', include(debug_toolbar.urls)),
]
# import debug_toolbar
from debug_toolbar.toolbar import debug_toolbar_urls
# urlpatterns += [
# path('__debug__/', include(debug_toolbar.urls)),
# ]
urlpatterns += debug_toolbar_urls()

0 comments on commit 73944cf

Please sign in to comment.