Skip to content

Commit

Permalink
improve global task listing view performance
Browse files Browse the repository at this point in the history
  • Loading branch information
longhotsummer committed Jan 5, 2024
1 parent 56a9ac8 commit 246dea8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions indigo_api/models/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def get_queryset(self):
from .documents import Document

return super(TaskManager, self).get_queryset() \
.select_related('created_by_user', 'updated_by_user', 'assigned_to', \
'submitted_by_user', 'reviewed_by_user', 'country', \
'country__country', 'locality') \
.select_related('created_by_user', 'updated_by_user', 'assigned_to',
'submitted_by_user', 'reviewed_by_user', 'country',
'country__country', 'locality', 'locality__country', 'locality__country__country') \
.prefetch_related(Prefetch('work', queryset=Work.objects.filter())) \
.prefetch_related(Prefetch('document', queryset=Document.objects.no_xml())) \
.prefetch_related('labels')
Expand Down
2 changes: 1 addition & 1 deletion indigo_app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class TaskFilterForm(forms.Form):
assigned_to = forms.ModelMultipleChoiceField(queryset=User.objects)
submitted_by = forms.ModelMultipleChoiceField(queryset=User.objects)
type = forms.MultipleChoiceField(choices=Task.CODES)
country = forms.ModelMultipleChoiceField(queryset=Country.objects)
country = forms.ModelMultipleChoiceField(queryset=Country.objects.select_related('country'))
taxonomy_topic = forms.CharField()

def __init__(self, country, *args, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions indigo_app/views/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ def get(self, request, *args, **kwargs):
def get_queryset(self):
tasks = Task.objects \
.filter(assigned_to=None, country__in=self.request.user.editor.permitted_countries.all())\
.select_related('document__language', 'document__language__language') \
.defer('document__document_xml')\
.order_by('-updated_at')

Expand Down

0 comments on commit 246dea8

Please sign in to comment.