From 8377e20b4b0c22a02f250a5b6a1d91ad9d9737a5 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Mon, 4 Nov 2024 22:28:18 +0100
Subject: [PATCH] Also filter personal notes on statistics page

---
 aleksis/apps/alsijil/schema/__init__.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/aleksis/apps/alsijil/schema/__init__.py b/aleksis/apps/alsijil/schema/__init__.py
index 2e6bb7ad8..58e7c7e9f 100644
--- a/aleksis/apps/alsijil/schema/__init__.py
+++ b/aleksis/apps/alsijil/schema/__init__.py
@@ -285,7 +285,14 @@ class Query(graphene.ObjectType):
         person = Person.objects.get(pk=person)
         if not info.context.user.has_perm("alsijil.view_person_statistics_rule", person):
             return []
-        return NewPersonalNote.objects.filter(person=person)
+        school_term = SchoolTerm.objects.get(id=term)
+        return NewPersonalNote.objects.filter(
+            person=person,
+            documentation__in=Documentation.objects.filter(
+                datetime_start__date__gte=school_term.date_start,
+                datetime_end__date__lte=school_term.date_end,
+            ),
+        )
 
     @staticmethod
     def resolve_statistics_by_group(root, info, group, term=None):
-- 
GitLab