Commit bb5ef01f authored by hypsug0's avatar hypsug0
Browse files

feat: Optimize perfs on session list

parent 872e73a9
......@@ -198,8 +198,22 @@ class SessionMyList(LoginRequiredMixin, SingleTableView):
def get_queryset(self):
loggeduser = self.request.user
return (
Session.objects.filter(
queryset = (
Session.objects.select_related("created_by")
.select_related("main_observer")
.prefetch_related("other_observer")
.select_related("place")
.select_related("contact")
.select_related("study")
.prefetch_related("observations")
.prefetch_related("observations__codesp")
.prefetch_related("place__municipality")
.prefetch_related("place__territory")
.prefetch_related("place__type")
.prefetch_related("place__type")
)
queryset = (
queryset.filter(
Q(created_by=loggeduser)
| Q(main_observer=loggeduser)
| Q(other_observer__username__contains=loggeduser.username)
......@@ -207,6 +221,7 @@ class SessionMyList(LoginRequiredMixin, SingleTableView):
.distinct()
.order_by("-timestamp_update")
)
return queryset
class DeviceCreate(LoginRequiredMixin, CreateView):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment