From d7e6fe662cbed470aaf455bf3bb6e65107316931 Mon Sep 17 00:00:00 2001 From: why-not-try-calmer Date: Sun, 7 Jan 2024 21:01:34 +0100 Subject: [PATCH] added missing distinct() --- comptages/core/report.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/comptages/core/report.py b/comptages/core/report.py index fdb95103..35ef524a 100644 --- a/comptages/core/report.py +++ b/comptages/core/report.py @@ -51,18 +51,20 @@ def _prepare_default_reports( sections_days: Optional[dict[str, list[date]]] = None, ): # We do by section and not by count because of special cases. - sections = models.Section.objects.filter(lane__id_installation__count=count) + sections = models.Section.objects.filter( + lane__id_installation__count=count + ).distinct() # Filter out sections if the user narrowed down the section to include # in report if sections_days: - sections = sections.filter(id__in=list(sections_days.keys())) + sections = sections.filter(id__in=list(sections_days.keys())).distinct() mondays = list(_mondays_of_count(count)) mondays_qty = len(mondays) QgsMessageLog.logMessage( - f"Reporting on {sections.distinct().count()} sections", "Report", Qgis.Info + f"Reporting on {sections.count()} sections", "Report", Qgis.Info ) for section in sections: for i, monday in enumerate(mondays):