Commit 5a947332 authored by hypsug0's avatar hypsug0
Browse files

Improve perfs and fix specie input on search form

parent 5913a469
......@@ -452,8 +452,10 @@ class PlaceFilteringMixin:
def get_queryset(self, *args, **kwargs):
qs = (
Place.objects.select_related("municipality")
.select_related("metaplace")
.select_related("creator")
.select_related("type")
.select_related("territory")
)
municipality = self.request.query_params.get("municipality", None)
......
......@@ -2,6 +2,7 @@
import logging
from django.contrib.auth.mixins import LoginRequiredMixin
from django.db.models import Prefetch
from rest_framework.generics import ListAPIView
from rest_framework.permissions import AllowAny, IsAuthenticated
......@@ -37,13 +38,11 @@ class GeoJSONSighting(
def get_queryset(self, *args, **kwargs):
qs = super(GeoJSONSighting, self).get_queryset()
qs = qs.select_related(
"created_by",
"codesp",
"session",
"session__contact",
"session__place",
"session__place__municipality",
qs = qs.select_related("created_by", "codesp", "session",).prefetch_related(
Prefetch("session__contact"),
Prefetch("session__place"),
Prefetch("session__place__municipality"),
Prefetch("session__place__territory"),
)
return qs.distinct().order_by("-timestamp_update")
......
......@@ -70,13 +70,14 @@
<input class="form-control form-control-sm" type="text" id="place_type" name="place_type"
placeholder="Type de localité">
</div>
<div class="form-group form-group-sm mr-2">
<label for="count_min">Effectif mini</label>
<input class="form-control form-control-sm" type="number" id="count_min" name="count_min"
placeholder="Effectif mini">
</div>
</div>
<div class="form-row">
<div class="form-group form-group-sm mr-2">
<label for="specie">Espèce</label>
<input class="form-control form-control-sm" type="text" id="specie" name="specie"
placeholder="Espèce">
</div>
<div class="form-group form-group-sm mr-2">
<label for="sex">Sexe</label>
<input class="form-control form-control-sm" type="text" id="sex" name="sex"
......@@ -92,6 +93,11 @@
<label for="age">Age</label>
<input class="form-control form-control-sm" type="text" id="age" name="age"
placeholder="Age">
</div>
<div class="form-group form-group-sm mr-2">
<label for="count_min">Effectif mini</label>
<input class="form-control form-control-sm" type="number" id="count_min" name="count_min"
placeholder="Effectif mini">
</div>
</div>
......
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