diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue index a5498363b3ac05acdeed5409e5e7728157482824..7d13ae630116e2f9a34ba5d8e8755b2b8710635c 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/StatisticsForPersonCard.vue @@ -52,6 +52,16 @@ export default { apollo: { statistics: { query: statisticsByPerson, + variables() { + const term = this.schoolTerm + ? { term: this.schoolTerm.id } + : {}; + + return { + person: this.person.id, + ...term, + }; + }, }, }, }; diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql index e9f1e5d52f4d5368762dfd64b07b2d0e6b667fc0..c9aa8e1ed5ad60c21772315730c323dc3997b0e4 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql +++ b/aleksis/apps/alsijil/frontend/components/coursebook/statistics/statistics.graphql @@ -28,7 +28,7 @@ fragment statistics on StatisticsByPersonType { query statisticsByPerson ( $person: ID! - $term: ID! + $term: ID ) { statistics: statisticsByPerson( person: $person @@ -40,7 +40,7 @@ query statisticsByPerson ( query statisticsByGroup ( $group: ID! - $term: ID! + $term: ID ) { statistics: statisticsByGroup( group: $group diff --git a/aleksis/apps/alsijil/schema/__init__.py b/aleksis/apps/alsijil/schema/__init__.py index c49e6e91c622392a591181aa21da51c7fdc62159..986256eba7d6d3a6ff068d8ce7c544d15a8ec864 100644 --- a/aleksis/apps/alsijil/schema/__init__.py +++ b/aleksis/apps/alsijil/schema/__init__.py @@ -51,13 +51,13 @@ class Query(graphene.ObjectType): statistics_by_person = graphene.Field( StatisticsByPersonType, - person=graphene.ID(), - term=graphene.ID(), + person=graphene.ID(required=True), + term=graphene.ID(required=False), ) statistics_by_group = graphene.List( StatisticsByPersonType, - group=graphene.ID(), - term=graphene.ID(), + group=graphene.ID(required=True), + term=graphene.ID(required=False), ) def resolve_documentations_by_course_id(root, info, course_id, **kwargs): @@ -183,12 +183,12 @@ class Query(graphene.ObjectType): return lessons_for_person @staticmethod - def resolve_statistics_by_person(root, info, person, term): + def resolve_statistics_by_person(root, info, person, term=None): # TODO: Annotate person with necessary information for term. return Person.objects.get(id=person) @staticmethod - def resolve_statistics_by_group(root, info, group, term): + def resolve_statistics_by_group(root, info, group, term=None): # TODO: Annotate persons with necessary information for term. return Group.objects.get(id=group).members.all()