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

Implement statistics query resolvers

parent b08ceda7
No related branches found
No related tags found
1 merge request!361Resolve "Add statistics page for absences"
...@@ -174,6 +174,16 @@ class Query(graphene.ObjectType): ...@@ -174,6 +174,16 @@ class Query(graphene.ObjectType):
return lessons_for_person 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): class Mutation(graphene.ObjectType):
create_or_update_documentations = DocumentationBatchCreateOrUpdateMutation.Field() create_or_update_documentations = DocumentationBatchCreateOrUpdateMutation.Field()
......
import graphene import graphene
from aleksis.apps.kolego.models.absence import AbsenceReason
from aleksis.apps.kolego.schema.absence import AbsenceReasonType from aleksis.apps.kolego.schema.absence import AbsenceReasonType
from ..models import ExtraMark
from .personal_note import ExtraMarkType from .personal_note import ExtraMarkType
class AbsenceReasonWithCountType(graphene.ObjectType): class AbsenceReasonWithCountType(graphene.ObjectType):
absence_reason = graphene.Field(AbsenceReasonType) absence_reason = graphene.Field(AbsenceReasonType)
count = graphene.Int() count = graphene.Int()
def resolve_count(root, info):
return 6
class ExtraMarkWithCountType(graphene.ObjectType): class ExtraMarkWithCountType(graphene.ObjectType):
extra_mark = graphene.Field(ExtraMarkType) extra_mark = graphene.Field(ExtraMarkType)
count = graphene.Int() count = graphene.Int()
def resolve_count(root, info):
return 7
class StatisticsByPersonType(graphene.ObjectType): class StatisticsByPersonType(graphene.ObjectType):
participation_count = graphene.Int() participation_count = graphene.Int()
absence_count = graphene.Int() absence_count = graphene.Int()
...@@ -17,3 +25,24 @@ class StatisticsByPersonType(graphene.ObjectType): ...@@ -17,3 +25,24 @@ class StatisticsByPersonType(graphene.ObjectType):
tardiness_sum = graphene.Int() tardiness_sum = graphene.Int()
tardiness_count = graphene.Int() tardiness_count = graphene.Int()
extra_marks = graphene.List(ExtraMarkWithCountType) 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()
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