From a4a45020f85d0a8779c8c9d9e171a41722ebef66 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                            | 8 ++++++++
 aleksis/apps/alsijil/model_extensions.py | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 1ee95a29f..03c15c23b 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file.
 The format is based on `Keep a Changelog`_,
 and this project adheres to `Semantic Versioning`_.
 
+Unreleased
+----------
+
+Fixed
+~~~~~
+
+* Absences with custom excuse types were always counted as 0 or 1.
+
 `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