diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql index af610d68d365061a4fbf7ac9ff4bd334c3b54e30..266702ea6a9a4e06d1a981d23ddf9f04fec44245 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql @@ -2,23 +2,27 @@ fragment statistics on StatisticsByPersonType { participationCount absenceCount absenceReasons { - id - shortName - name - colour - countAsAbsent count + absenceReason { + id + shortName + name + colour + countAsAbsent + } } tardinessSum tardinessCount extraMarks { - id - shortName - name - colourFg - colourBg - showInCourseBook count + extraMark { + id + shortName + name + colourFg + colourBg + showInCourseBook + } } } diff --git a/aleksis/apps/alsijil/schema/__init__.py b/aleksis/apps/alsijil/schema/__init__.py index 46174ddb72be862898d316c6e08078baf25496ca..6ac95c44e837cf658aa4c8c5ecd91b2c6fd1f59b 100644 --- a/aleksis/apps/alsijil/schema/__init__.py +++ b/aleksis/apps/alsijil/schema/__init__.py @@ -22,6 +22,7 @@ from .absences import ( LessonsForPersonType, AbsencesBatchCreateMutation, ) +from .statistics import StatisticsByPersonType class Query(graphene.ObjectType): documentations = FilterOrderList(DocumentationType) @@ -48,6 +49,9 @@ class Query(graphene.ObjectType): end=graphene.Date(required=True), ) + statistics_by_person = graphene.Field(StatisticsByPersonType) + statistics_by_group = graphene.List(StatisticsByPersonType) + def resolve_documentations_by_course_id(root, info, course_id, **kwargs): documentations = Documentation.objects.filter( Q(course__pk=course_id) | Q(amends__course__pk=course_id) diff --git a/aleksis/apps/alsijil/schema/statistics.py b/aleksis/apps/alsijil/schema/statistics.py new file mode 100644 index 0000000000000000000000000000000000000000..ed9fff17b5b87887e02ec4312d93717f90e4f065 --- /dev/null +++ b/aleksis/apps/alsijil/schema/statistics.py @@ -0,0 +1,19 @@ +import graphene +from aleksis.apps.kolego.schema.absence import AbsenceReasonType +from .personal_note import ExtraMarkType + +class AbsenceReasonWithCountType(graphene.ObjectType): + absence_reason = graphene.Field(AbsenceReasonType) + count = graphene.Int() + +class ExtraMarkWithCountType(graphene.ObjectType): + extra_mark = graphene.Field(ExtraMarkType) + count = graphene.Int() + +class StatisticsByPersonType(graphene.ObjectType): + participation_count = graphene.Int() + absence_count = graphene.Int() + absence_reasons = graphene.List(AbsenceReasonWithCountType) + tardiness_sum = graphene.Int() + tardiness_count = graphene.Int() + extra_marks = graphene.List(ExtraMarkWithCountType)