From 2fa8af88c1601eb6c5fa09f92f1296cd59827280 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Thu, 23 Mar 2023 20:08:04 +0100
Subject: [PATCH] Fix distinct query for absences with custom excuse types

---
 CHANGELOG.rst                            | 2 ++
 aleksis/apps/alsijil/model_extensions.py | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 540930966..2570ecf95 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -11,9 +11,11 @@ Unreleased
 
 Fixed
 ~~~~~
+
 * In some cases, pages showing the count of extra marks and lessons with custom excuse types of
   persons threw an error.
 * The redirection to generated class register PDF printouts did not work.
+* Absences with custom excuse types were not counted correctly.
 
 `3.0b0`_ - 2022-02-28
 ---------------------
diff --git a/aleksis/apps/alsijil/model_extensions.py b/aleksis/apps/alsijil/model_extensions.py
index 60504010d..8a92d6671 100644
--- a/aleksis/apps/alsijil/model_extensions.py
+++ b/aleksis/apps/alsijil/model_extensions.py
@@ -482,7 +482,7 @@ def generate_person_list_with_class_register_statistics(
         persons = persons.annotate(
             **{
                 excuse_type.count_label: Count(
-                    "filtered_personal_notes__absent",
+                    "filtered_personal_notes",
                     filter=Q(
                         filtered_personal_notes__absent=True,
                         filtered_personal_notes__excuse_type=excuse_type,
-- 
GitLab