73 lines
1.4 KiB
JavaScript
73 lines
1.4 KiB
JavaScript
import gql from 'graphql-tag'
|
|
import { options } from '@/data'
|
|
|
|
export const apolloTheses = {
|
|
query: gql`{
|
|
allQuestions(orderBy: ID_ASC) {
|
|
nodes {
|
|
category: categoryByCategoryId {
|
|
title
|
|
}
|
|
text
|
|
id
|
|
}
|
|
}
|
|
}`,
|
|
update: data => data.allQuestions.nodes.map(node => ({
|
|
id: node.id,
|
|
thesis: {
|
|
de: node.text
|
|
},
|
|
category: {
|
|
de: node.category.title
|
|
}
|
|
}))
|
|
}
|
|
|
|
export const apolloThesesCount = {
|
|
query: gql`{
|
|
allQuestions {
|
|
totalCount
|
|
}
|
|
}`,
|
|
update: data => data.allQuestions.totalCount
|
|
}
|
|
|
|
function getPositionById (id) {
|
|
return options.find(option => option.id === id).position
|
|
}
|
|
|
|
export const apolloPersonsForResults = {
|
|
query: gql`{
|
|
allPeople(condition: {role: CANDYMAT_CANDIDATE}) {
|
|
nodes {
|
|
firstName
|
|
lastName
|
|
id
|
|
answersByPersonId {
|
|
nodes {
|
|
position
|
|
questionId
|
|
text
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}`
|
|
}
|
|
|
|
export function parseApolloPersonForResults (data) {
|
|
return data.allPeople.nodes.map(person => ({
|
|
id: person.id,
|
|
name: `${person.firstName} ${person.lastName}`,
|
|
token: person.firstName.charAt(0) + person.lastName.charAt(0),
|
|
positions: person.answersByPersonId.nodes.map(answer => ({
|
|
thesis: answer.questionId,
|
|
position: getPositionById(answer.position),
|
|
statement: {
|
|
de: answer.text
|
|
}
|
|
}))
|
|
}))
|
|
}
|