Fix heavy request for getting user maps
This was creating a huge INNER JOIN, and is replaced by a UNION cf https://explain.dalibo.com/plan/91af244fg9d1ec21 Also remove the conditional queryset, as now "my maps" is serverd by the dashboard page, so we can only serve public maps on this URL.
This commit is contained in:
parent
0db7f377c3
commit
9af5375dbf
1 changed files with 4 additions and 8 deletions
|
@ -205,13 +205,10 @@ class UserMaps(PaginatorMixin, DetailView):
|
||||||
return settings.UMAP_MAPS_PER_PAGE_OWNER
|
return settings.UMAP_MAPS_PER_PAGE_OWNER
|
||||||
return settings.UMAP_MAPS_PER_PAGE
|
return settings.UMAP_MAPS_PER_PAGE
|
||||||
|
|
||||||
def get_map_queryset(self):
|
|
||||||
return Map.objects if self.is_owner() else Map.public
|
|
||||||
|
|
||||||
def get_maps(self):
|
def get_maps(self):
|
||||||
qs = self.get_map_queryset()
|
qs = Map.public
|
||||||
qs = qs.filter(Q(owner=self.object) | Q(editors=self.object))
|
qs = qs.filter(owner=self.object).union(qs.filter(editors=self.object))
|
||||||
return qs.distinct().order_by("-modified_at")
|
return qs.order_by("-modified_at")
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs.update({"maps": self.paginate(self.get_maps(), self.per_page)})
|
kwargs.update({"maps": self.paginate(self.get_maps(), self.per_page)})
|
||||||
|
@ -225,9 +222,8 @@ class UserStars(UserMaps):
|
||||||
template_name = "auth/user_stars.html"
|
template_name = "auth/user_stars.html"
|
||||||
|
|
||||||
def get_maps(self):
|
def get_maps(self):
|
||||||
qs = self.get_map_queryset()
|
|
||||||
stars = Star.objects.filter(by=self.object).values("map")
|
stars = Star.objects.filter(by=self.object).values("map")
|
||||||
qs = qs.filter(pk__in=stars)
|
qs = Map.public.filter(pk__in=stars)
|
||||||
return qs.order_by("-modified_at")
|
return qs.order_by("-modified_at")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue