Skip to content

Commit

Permalink
added testfeidenavn and correct query
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgtho committed Sep 26, 2023
1 parent 2741be3 commit 55fb4f2
Show file tree
Hide file tree
Showing 4 changed files with 4,674 additions and 3,097 deletions.
3 changes: 1 addition & 2 deletions Documents/build-document-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const config = require('../config')

module.exports.getStudentDocumentsQuery = (students, type, id, teacher) => {
let query = { $or: [] }

const contactStudents = students.filter(student => student.isContactTeacher || student.contactTeacher).map(student => student.username || student.userName)
const courseStudents = students.filter(student => !(student.isContactTeacher || student.contactTeacher)).map(student => student.username || student.userName)

Expand All @@ -20,7 +19,7 @@ module.exports.getStudentDocumentsQuery = (students, type, id, teacher) => {
$in: courseStudents
},
$or: [
{ type: 'varsel', variant: 'fag', 'content.classes.id': { $in: teacher.groupIds } },
{ type: 'varsel', variant: 'fag' },
{ type: 'notat' }
]
})
Expand Down
3 changes: 2 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ module.exports = {
FINT_API_URL: process.env.FINT_API_URL || '',
FINT_BETA: (process.env.FINT_BETA && process.env.FINT_BETA === 'true') || false,
FINT_JWT_SECRET: process.env.FINT_JWT_SECRET || false,
FINT_TIMEOUT: (process.env.FINT_TIMEOUT && Number.parseInt(process.env.FINT_TIMEOUT)) || 0
FINT_TIMEOUT: (process.env.FINT_TIMEOUT && Number.parseInt(process.env.FINT_TIMEOUT)) || 0,
TEST_FEIDENAVN: process.env.TEST_FEIDENAVN ? process.env.TEST_FEIDENAVN.split(',') : []
}
38 changes: 37 additions & 1 deletion lib/get-fint-data.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { logger } = require('@vtfk/logger')
const axios = require('axios').default
const generateJwt = require('./generate-system-jwt')
const { FINT_API_URL, FINT_JWT_SECRET, FINT_TIMEOUT, FINT_BETA } = require('../config')
const { FINT_API_URL, FINT_JWT_SECRET, FINT_TIMEOUT, FINT_BETA, TEST_FEIDENAVN } = require('../config')

const callFint = async (query) => {
const token = generateJwt(FINT_JWT_SECRET)
Expand All @@ -18,6 +18,42 @@ const callFint = async (query) => {
}

const getFaggrupper = async (feidenavn) => {
// Check if we need testdata
if (TEST_FEIDENAVN.includes(feidenavn)) {
return [
{
id: '12473601',
groupId: 'TULL:B2/KØDD3035',
type: 'faggruppe',
name: 'B2/KØDD3035',
description: 'Faggruppe B2/KØDD3035 ved Tull videregående skole',
schoolId: '38018',
schoolName: 'Tull videregående skole',
grep: {
id: '7f0681ae-3b27-4f0e-98b3-34c94c8d7c8f',
kode: 'KØDD3035',
url: 'http://psi.udir.no/kl06/KØDD3035',
data_url: 'https://data.udir.no/kl06/v201906/fagkoder/KØDD3035',
tittel: {
default: 'Master i å slå seg sammen for så å splittes igjen',
nob: 'Master i å slå seg sammen for så å splittes igjen',
nno: 'Master i å slå seg sammen for så å splittes igjen',
eng: 'Master i å slå seg sammen for så å splittes igjen',
sme: 'Master i å slå seg sammen for så å splittes igjen'
},
kortform: {
default: 'Idioti',
nob: 'Idioti',
nno: 'Idioti',
eng: 'Idioti',
sme: 'Idioti'
}
},
updatedAt: '2023-09-25T14:02:23.647Z'
}
]
}

const query = {
query: `
query {
Expand Down
Loading

0 comments on commit 55fb4f2

Please sign in to comment.