From 4c79b1956dc727dc6ef9deae3e6ea85dfec39e17 Mon Sep 17 00:00:00 2001
From: Michael Bauer <michael-bauer@posteo.de>
Date: Fri, 31 May 2024 13:58:31 +0200
Subject: [PATCH] Return school-term for statistics-by-person-query

Query can send no school-term and will receive the result for the
current school-term. With the additional school-term parameter the
frontend now knows which school-term is current.
---
 .../components/coursebook/statistics/statistics.graphql       | 1 +
 aleksis/apps/alsijil/schema/statistics.py                     | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql
index c9aa8e1ed..09f07ba47 100644
--- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql
+++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql
@@ -1,4 +1,5 @@
 fragment statistics on StatisticsByPersonType {
+  schoolTerm
   participationCount
   absenceCount
   absenceReasons {
diff --git a/aleksis/apps/alsijil/schema/statistics.py b/aleksis/apps/alsijil/schema/statistics.py
index ee3dd29b3..3f673666b 100644
--- a/aleksis/apps/alsijil/schema/statistics.py
+++ b/aleksis/apps/alsijil/schema/statistics.py
@@ -27,6 +27,7 @@ class ExtraMarkWithCountType(graphene.ObjectType):
 
 
 class StatisticsByPersonType(graphene.ObjectType):
+    school_term = graphene.Int()
     participation_count = graphene.Int()
     absence_count = graphene.Int()
     absence_reasons = graphene.List(AbsenceReasonWithCountType)
@@ -34,6 +35,9 @@ class StatisticsByPersonType(graphene.ObjectType):
     tardiness_count = graphene.Int()
     extra_marks = graphene.List(ExtraMarkWithCountType)
 
+    def resolve_school_term(root, info):
+        return 1
+
     def resolve_participation_count(root, info):
         return 3
 
-- 
GitLab