diff --git a/aleksis/apps/alsijil/schema/__init__.py b/aleksis/apps/alsijil/schema/__init__.py index 6ac95c44e837cf658aa4c8c5ecd91b2c6fd1f59b..0c7c299f08a10f6502646f0304863c322f129f1c 100644 --- a/aleksis/apps/alsijil/schema/__init__.py +++ b/aleksis/apps/alsijil/schema/__init__.py @@ -174,6 +174,16 @@ class Query(graphene.ObjectType): return lessons_for_person + @staticmethod + def resolve_statistics_by_person(root, info, person_id, term_id): + # TODO: Annotate person with necessary information for term_id. + return Person.objects.get(id=person_id) + + @staticmethod + def resolve_statistics_by_group(root, info, group_id, term_id): + # TODO: Annotate persons with necessary information for term_id. + return Group.objects.get(id=group_id).members.all() + class Mutation(graphene.ObjectType): create_or_update_documentations = DocumentationBatchCreateOrUpdateMutation.Field() diff --git a/aleksis/apps/alsijil/schema/statistics.py b/aleksis/apps/alsijil/schema/statistics.py index ed9fff17b5b87887e02ec4312d93717f90e4f065..37b8937844636fe6cec8a5c52f7db2e7e9b1ab47 100644 --- a/aleksis/apps/alsijil/schema/statistics.py +++ b/aleksis/apps/alsijil/schema/statistics.py @@ -1,15 +1,23 @@ import graphene +from aleksis.apps.kolego.models.absence import AbsenceReason from aleksis.apps.kolego.schema.absence import AbsenceReasonType +from ..models import ExtraMark from .personal_note import ExtraMarkType class AbsenceReasonWithCountType(graphene.ObjectType): absence_reason = graphene.Field(AbsenceReasonType) count = graphene.Int() + def resolve_count(root, info): + return 6 + class ExtraMarkWithCountType(graphene.ObjectType): extra_mark = graphene.Field(ExtraMarkType) count = graphene.Int() + def resolve_count(root, info): + return 7 + class StatisticsByPersonType(graphene.ObjectType): participation_count = graphene.Int() absence_count = graphene.Int() @@ -17,3 +25,24 @@ class StatisticsByPersonType(graphene.ObjectType): tardiness_sum = graphene.Int() tardiness_count = graphene.Int() extra_marks = graphene.List(ExtraMarkWithCountType) + + def resolve_participation_count(root, info): + return 3 + + def resolve_absence_count(root, info): + return 1 + + def resolve_absence_reasons(root, info): + # TODO: Return actual AbsenceReasons + # Needed by resolve_absence_count as well. + return AbsenceReason.objects.all() + + def resolve_tardiness_sum(root, info): + return 17 + + def resolve_tardiness_count(root, info): + return 5 + + def resolve_extra_marks(root, info): + # TODO: Return actual ExtraMarks + return ExtraMark.objects.all()