mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2025-01-15 02:19:18 +01:00
speed up dashboard queries by using select_related (fixes #233)
This commit is contained in:
parent
1524cb4ca1
commit
b1b1f93e1e
@ -62,18 +62,18 @@ def dashboard(request):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# open & reopened tickets, assigned to current user
|
# open & reopened tickets, assigned to current user
|
||||||
tickets = Ticket.objects.filter(
|
tickets = Ticket.objects.select_related('queue').filter(
|
||||||
assigned_to=request.user,
|
assigned_to=request.user,
|
||||||
).exclude(
|
).exclude(
|
||||||
status__in = [Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS],
|
status__in = [Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS],
|
||||||
)
|
)
|
||||||
|
|
||||||
# closed & resolved tickets, assigned to current user
|
# closed & resolved tickets, assigned to current user
|
||||||
tickets_closed_resolved = Ticket.objects.filter(
|
tickets_closed_resolved = Ticket.objects.select_related('queue').filter(
|
||||||
assigned_to=request.user,
|
assigned_to=request.user,
|
||||||
status__in = [Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS])
|
status__in = [Ticket.CLOSED_STATUS, Ticket.RESOLVED_STATUS])
|
||||||
|
|
||||||
unassigned_tickets = Ticket.objects.filter(
|
unassigned_tickets = Ticket.objects.select_related('queue').filter(
|
||||||
assigned_to__isnull=True,
|
assigned_to__isnull=True,
|
||||||
).exclude(
|
).exclude(
|
||||||
status=Ticket.CLOSED_STATUS,
|
status=Ticket.CLOSED_STATUS,
|
||||||
@ -83,7 +83,7 @@ def dashboard(request):
|
|||||||
all_tickets_reported_by_current_user = ''
|
all_tickets_reported_by_current_user = ''
|
||||||
email_current_user = request.user.email
|
email_current_user = request.user.email
|
||||||
if email_current_user:
|
if email_current_user:
|
||||||
all_tickets_reported_by_current_user = Ticket.objects.filter(
|
all_tickets_reported_by_current_user = Ticket.objects.select_related('queue').filter(
|
||||||
submitter_email=email_current_user,
|
submitter_email=email_current_user,
|
||||||
).order_by('status')
|
).order_by('status')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user