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

Fix statistics query

parent a2ba6354
No related branches found
No related tags found
1 merge request!361Resolve "Add statistics page for absences"
...@@ -31,7 +31,7 @@ import StatisticsTardinessCard from "./StatisticsTardinessCard.vue"; ...@@ -31,7 +31,7 @@ import StatisticsTardinessCard from "./StatisticsTardinessCard.vue";
import StatisticsExtraMarksCard from "./StatisticsExtraMarksCard.vue"; import StatisticsExtraMarksCard from "./StatisticsExtraMarksCard.vue";
import StatisticsPersonalNotesList from "./StatisticsPersonalNotesList.vue"; import StatisticsPersonalNotesList from "./StatisticsPersonalNotesList.vue";
import statisticsByPerson from "./statistics.graphql"; import { statisticsByPerson } from "./statistics.graphql";
export default { export default {
name: "StatisticsForPersonCard", name: "StatisticsForPersonCard",
......
...@@ -8,7 +8,7 @@ fragment statistics on StatisticsByPersonType { ...@@ -8,7 +8,7 @@ fragment statistics on StatisticsByPersonType {
shortName shortName
name name
colour colour
countAsAbsent default
} }
} }
tardinessSum tardinessSum
...@@ -21,34 +21,36 @@ fragment statistics on StatisticsByPersonType { ...@@ -21,34 +21,36 @@ fragment statistics on StatisticsByPersonType {
name name
colourFg colourFg
colourBg colourBg
showInCourseBook showInCoursebook
} }
} }
} }
query statisticsByPerson ( query statisticsByPerson (
$personId: ID! $person: ID!
$termId: ID! $term: ID!
) { ) {
statistics: statisticsByPerson( statistics: statisticsByPerson(
$personId: ID! person: $person
$termId: ID! term: $term
) { ) {
...statistics ...statistics
}
} }
query statisticsByGroup ( query statisticsByGroup (
$groupId: ID! $group: ID!
$termId: ID! $term: ID!
) { ) {
statistics: statisticsByGroup( statistics: statisticsByGroup(
$groupId: ID! group: $group
$termId: ID! term: $term
) { ) {
persons { persons {
id id
firstName firstName
lastName lastName
...statistics ...statistics
}
} }
} }
...@@ -49,8 +49,16 @@ class Query(graphene.ObjectType): ...@@ -49,8 +49,16 @@ class Query(graphene.ObjectType):
end=graphene.Date(required=True), end=graphene.Date(required=True),
) )
statistics_by_person = graphene.Field(StatisticsByPersonType) statistics_by_person = graphene.Field(
statistics_by_group = graphene.List(StatisticsByPersonType) StatisticsByPersonType,
person=graphene.ID(),
term=graphene.ID(),
)
statistics_by_group = graphene.List(
StatisticsByPersonType,
group=graphene.ID(),
term=graphene.ID(),
)
def resolve_documentations_by_course_id(root, info, course_id, **kwargs): def resolve_documentations_by_course_id(root, info, course_id, **kwargs):
documentations = Documentation.objects.filter( documentations = Documentation.objects.filter(
...@@ -175,14 +183,14 @@ class Query(graphene.ObjectType): ...@@ -175,14 +183,14 @@ class Query(graphene.ObjectType):
return lessons_for_person return lessons_for_person
@staticmethod @staticmethod
def resolve_statistics_by_person(root, info, person_id, term_id): def resolve_statistics_by_person(root, info, person, term):
# TODO: Annotate person with necessary information for term_id. # TODO: Annotate person with necessary information for term.
return Person.objects.get(id=person_id) return Person.objects.get(id=person)
@staticmethod @staticmethod
def resolve_statistics_by_group(root, info, group_id, term_id): def resolve_statistics_by_group(root, info, group, term):
# TODO: Annotate persons with necessary information for term_id. # TODO: Annotate persons with necessary information for term.
return Group.objects.get(id=group_id).members.all() return Group.objects.get(id=group).members.all()
class Mutation(graphene.ObjectType): class Mutation(graphene.ObjectType):
......
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