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

Make school term query arg optional and adapt to core

person & schoolTerm are both objects now in personOverviewCardMixin.
parent 8dfd2d8b
No related branches found
No related tags found
1 merge request!361Resolve "Add statistics page for absences"
...@@ -52,6 +52,16 @@ export default { ...@@ -52,6 +52,16 @@ export default {
apollo: { apollo: {
statistics: { statistics: {
query: statisticsByPerson, query: statisticsByPerson,
variables() {
const term = this.schoolTerm
? { term: this.schoolTerm.id }
: {};
return {
person: this.person.id,
...term,
};
},
}, },
}, },
}; };
......
...@@ -28,7 +28,7 @@ fragment statistics on StatisticsByPersonType { ...@@ -28,7 +28,7 @@ fragment statistics on StatisticsByPersonType {
query statisticsByPerson ( query statisticsByPerson (
$person: ID! $person: ID!
$term: ID! $term: ID
) { ) {
statistics: statisticsByPerson( statistics: statisticsByPerson(
person: $person person: $person
...@@ -40,7 +40,7 @@ query statisticsByPerson ( ...@@ -40,7 +40,7 @@ query statisticsByPerson (
query statisticsByGroup ( query statisticsByGroup (
$group: ID! $group: ID!
$term: ID! $term: ID
) { ) {
statistics: statisticsByGroup( statistics: statisticsByGroup(
group: $group group: $group
......
...@@ -51,13 +51,13 @@ class Query(graphene.ObjectType): ...@@ -51,13 +51,13 @@ class Query(graphene.ObjectType):
statistics_by_person = graphene.Field( statistics_by_person = graphene.Field(
StatisticsByPersonType, StatisticsByPersonType,
person=graphene.ID(), person=graphene.ID(required=True),
term=graphene.ID(), term=graphene.ID(required=False),
) )
statistics_by_group = graphene.List( statistics_by_group = graphene.List(
StatisticsByPersonType, StatisticsByPersonType,
group=graphene.ID(), group=graphene.ID(required=True),
term=graphene.ID(), term=graphene.ID(required=False),
) )
def resolve_documentations_by_course_id(root, info, course_id, **kwargs): def resolve_documentations_by_course_id(root, info, course_id, **kwargs):
...@@ -183,12 +183,12 @@ class Query(graphene.ObjectType): ...@@ -183,12 +183,12 @@ class Query(graphene.ObjectType):
return lessons_for_person return lessons_for_person
@staticmethod @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. # TODO: Annotate person with necessary information for term.
return Person.objects.get(id=person) return Person.objects.get(id=person)
@staticmethod @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. # TODO: Annotate persons with necessary information for term.
return Group.objects.get(id=group).members.all() return Group.objects.get(id=group).members.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