Skip to content

Commit

Permalink
Prefetch latest_translation__approved_user (mozilla#3106)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathjazz authored Feb 21, 2024
1 parent 0afb7d7 commit 4cf62b9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pontoon/administration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def admin(request):

projects = (
Project.objects.all()
.prefetch_related("latest_translation__user")
.prefetch_related(
"latest_translation__user", "latest_translation__approved_user"
)
.order_by("name")
)

Expand Down
4 changes: 2 additions & 2 deletions pontoon/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def prefetch_project_locale(self, project):
"project_locale",
queryset=(
ProjectLocale.objects.filter(project=project).prefetch_related(
"latest_translation__user"
"latest_translation__user", "latest_translation__approved_user"
)
),
to_attr="fetched_project_locale",
Expand Down Expand Up @@ -1210,7 +1210,7 @@ def prefetch_project_locale(self, locale):
"project_locale",
queryset=(
ProjectLocale.objects.filter(locale=locale).prefetch_related(
"latest_translation__user"
"latest_translation__user", "latest_translation__approved_user"
)
),
to_attr="fetched_project_locale",
Expand Down
4 changes: 3 additions & 1 deletion pontoon/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def projects(request):
projects = (
Project.objects.visible()
.visible_for(request.user)
.prefetch_related("latest_translation__user")
.prefetch_related(
"latest_translation__user", "latest_translation__approved_user"
)
.order_by("name")
)

Expand Down
4 changes: 3 additions & 1 deletion pontoon/teams/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@

def teams(request):
"""List all active localization teams."""
locales = Locale.objects.available().prefetch_related("latest_translation__user")
locales = Locale.objects.available().prefetch_related(
"latest_translation__user", "latest_translation__approved_user"
)

form = LocaleRequestForm()

Expand Down

0 comments on commit 4cf62b9

Please sign in to comment.