tentative d'amélioration des requêtes

This commit is contained in:
Jean-Marie Favreau 2024-12-13 16:14:05 +01:00
parent f9f690cac7
commit 290faf0b8f

View File

@ -895,15 +895,15 @@ def administration(request):
daily_modifications = Event.get_count_modifications([(d, 1) for d in days])
# get last created events
events = Event.objects.all().order_by("-created_date")[:5]
events = Event.objects.all().order_by("-created_date").select_related("exact_location", "category")[:5]
# get last batch imports
batch_imports = BatchImportation.objects.all().order_by("-created_date")[:5]
batch_imports = BatchImportation.objects.all().select_related("recurrentImport").order_by("-created_date")[:5]
# get info about batch information
newest = BatchImportation.objects.filter(recurrentImport=OuterRef("pk")).order_by(
"-created_date"
)
).select_related("recurrentImport")
imported_events = RecurrentImport.objects.annotate(
last_run_status=Subquery(newest.values("status")[:1])
)
@ -929,7 +929,7 @@ def administration(request):
Q(other_versions__representative__isnull=True)).values("start_day").\
annotate(not_moderated=Count("start_day", filter=Q(moderated_date__isnull=True))). \
annotate(nb_events=Count("start_day")). \
order_by("start_day")
order_by("start_day").values("not_moderated", "nb_events", "start_day")
max_not_moderated = max([x["not_moderated"] for x in nb_not_moderated])
if max_not_moderated == 0: