Skip to content
Snippets Groups Projects
Commit b08ceda7 authored by permcu's avatar permcu
Browse files

Implement statistics query types

Using count wrapper types to avoid duplicating the counted types.
parent 494615ab
No related branches found
No related tags found
1 merge request!361Resolve "Add statistics page for absences"
......@@ -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
}
}
}
......
......@@ -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)
......
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment