Skip to content

Commit

Permalink
added missing distinct()
Browse files Browse the repository at this point in the history
  • Loading branch information
why-not-try-calmer committed Jan 7, 2024
1 parent 28f7569 commit d7e6fe6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions comptages/core/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit d7e6fe6

Please sign in to comment.