From 506306aa3793aca6b54972ffca8a0c05040d764d Mon Sep 17 00:00:00 2001 From: amirhossein-haerian Date: Tue, 10 Sep 2024 14:14:53 +0200 Subject: [PATCH 1/5] feat(KUI-1425): the unused properties from koppsAPI is now removed --- .env.in | 6 ++++- config/serverSettings.js | 13 +++++++++++ server/controllers/memoCtrl.js | 23 ++++++++----------- server/koppsApi.js | 8 +------ server/ssr-context/createServerSideContext.js | 1 - test/mock-api/responses.js | 4 +--- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/.env.in b/.env.in index f89541ca..6ba352ad 100644 --- a/.env.in +++ b/.env.in @@ -1,4 +1,8 @@ KURS_PM_DATA_API_KEY=[Available in Azure KeyVault] KURSPLAN_API_KEY=[Available in Azure KeyVault] -REDIS_URI=[Available in Azure KeyVault] \ No newline at end of file +REDIS_URI=[Available in Azure KeyVault] + +# Ladok Mellanlager connection +LADOK_AUTH_CLIENT_SECRET=[Available in Azure KeyVault] +LADOK_OCP_APIM_SUBSCRIPTION_KEY=[Available in Azure KeyVault] \ No newline at end of file diff --git a/config/serverSettings.js b/config/serverSettings.js index ec6078ac..9ca867fe 100644 --- a/config/serverSettings.js +++ b/config/serverSettings.js @@ -49,6 +49,19 @@ module.exports = { kursplanApi: unpackNodeApiConfig('KURSPLAN_API_URI', devKursplanApi), }, + // TODO(Ladok-POC): Replace devDefaults and add values to ref/prod.parameters.json when final mellanlager is deployed + ladokMellanlagerApi: { + clientId: getEnv('LADOK_AUTH_CLIENT_ID', devDefaults('fc1c0e6e-c17b-4b1c-9e34-003ca528740f')), + clientSecret: getEnv('LADOK_AUTH_CLIENT_SECRET', null), + tokenUrl: getEnv( + 'LADOK_AUTH_TOKEN_URL', + devDefaults('https://login.microsoftonline.com/acd7f330-d613-48d9-85f2-258b1ac4a015/oauth2/v2.0/token') + ), + scope: getEnv('LADOK_AUTH_SCOPE', devDefaults('api://97fe6696-a7b2-4f7f-adce-726426e35c1c/.default')), + baseUrl: getEnv('LADOK_BASE_URL', devDefaults('https://apim-mellanlagring2.azure-api.net')), + ocpApimSupscriptionKey: getEnv('LADOK_OCP_APIM_SUBSCRIPTION_KEY', null), + }, + // koppsApi: unpackKOPPSConfig('KOPPS_URI', devKoppsApi), koppsApi: unpackNodeApiConfig('KOPPS_URI', devKoppsApi), diff --git a/server/controllers/memoCtrl.js b/server/controllers/memoCtrl.js index 49c20725..cba87a16 100644 --- a/server/controllers/memoCtrl.js +++ b/server/controllers/memoCtrl.js @@ -200,19 +200,13 @@ async function getContent(req, res, next) { let fromTerm = semester ?? extractTerm(courseCode, finalMemoEndPoint) - const { - courseMainSubjects, - recruitmentText, - title, - credits, - creditUnitAbbr, - infoContactName, - examiners, - roundInfos, - } = await getDetailedInformation(courseCode, languagesContext.memoLanguage, fromTerm) + const { title, credits, creditUnitAbbr, infoContactName, examiners, roundInfos } = await getDetailedInformation( + courseCode, + languagesContext.memoLanguage, + fromTerm + ) const courseContext = { - courseMainSubjects, title, credits, creditUnitAbbr, @@ -330,11 +324,12 @@ async function getOldContent(req, res, next) { memoDatas: [], } - const { courseMainSubjects, recruitmentText, title, credits, creditUnitAbbr, infoContactName, examiners } = - await getDetailedInformation(courseCode, languagesContext.memoLanguage) + const { title, credits, creditUnitAbbr, infoContactName, examiners } = await getDetailedInformation( + courseCode, + languagesContext.memoLanguage + ) const courseContext = { - courseMainSubjects, title, credits, creditUnitAbbr, diff --git a/server/koppsApi.js b/server/koppsApi.js index c84d9999..d19c3969 100644 --- a/server/koppsApi.js +++ b/server/koppsApi.js @@ -55,15 +55,13 @@ async function getDetailedInformation(courseCode, language, fromTerm) { try { const res = await client.getAsync({ uri, useCache: true }) if (res.body) { - const { mainSubjects, course, examiners, roundInfos } = res.body + const { course, examiners, roundInfos } = res.body const isCreditNotStandard = course && course.credits && course.credits.toString().indexOf('.') < 0 && course.credits.toString().indexOf(',') < 0 return { - courseMainSubjects: mainSubjects && mainSubjects.length > 0 ? mainSubjects.join(', ') : '', - recruitmentText: course && course.recruitmentText ? course.recruitmentText : '', title: course && course.title ? course.title : '', credits: isCreditNotStandard ? course.credits + '.0' : course.credits || '', creditUnitAbbr: course && course.creditUnitAbbr ? course.creditUnitAbbr : '', @@ -83,8 +81,6 @@ async function getDetailedInformation(courseCode, language, fromTerm) { language ) return { - courseMainSubjects: '', - recruitmentText: '', title: '', credits: '', creditUnitAbbr: '', @@ -94,8 +90,6 @@ async function getDetailedInformation(courseCode, language, fromTerm) { } catch (err) { log.error('Kopps is not available', err) return { - courseMainSubjects: '', - recruitmentText: '', title: '', credits: '', creditUnitAbbr: '', diff --git a/server/ssr-context/createServerSideContext.js b/server/ssr-context/createServerSideContext.js index cf95beaf..310f3904 100644 --- a/server/ssr-context/createServerSideContext.js +++ b/server/ssr-context/createServerSideContext.js @@ -15,7 +15,6 @@ function createServerSideContext() { const context = { browserConfig: {}, courseCode: '', - courseMainSubjects: '', language: 'sv', memoData: {}, memoDatas: [], diff --git a/test/mock-api/responses.js b/test/mock-api/responses.js index faae36fd..1b5e665d 100644 --- a/test/mock-api/responses.js +++ b/test/mock-api/responses.js @@ -82,8 +82,6 @@ module.exports = { titleOther: 'Algebra and Geometry', cancelled: false, deactivated: false, - recruitmentText: - '

Algebra och geometri är en grundläggande kurs i linjär algebra med vektorgeometri. Ett centralt begrepp i kursen är linjäritet som ligger till grund för stora delar av användningen av matematik inom såväl naturvetenskap som inom ingenjörstillämpningar.

', credits: 7.5, creditUnitLabel: 'Högskolepoäng', creditUnitAbbr: 'hp', @@ -1118,7 +1116,7 @@ module.exports = { }, }, ], - mainSubjects: ['Matematik', 'Teknik'], + // mainSubjects: ['Matematik', 'Teknik'], examinationSets: { 20072: { startingTerm: { From b7632b8dc5d52cb7c7872ea8bb01b8dc8f1481da Mon Sep 17 00:00:00 2001 From: amirhossein-haerian Date: Fri, 13 Sep 2024 12:47:59 +0200 Subject: [PATCH 2/5] feat(KUI-1425): ladok mellanlager is now being used in this repo --- package-lock.json | 12 +++++++ package.json | 1 + public/js/app/pages/AboutCourseMemo.jsx | 11 ++----- server/controllers/controllerFunctions.js | 24 ++++++++++++++ server/controllers/memoCtrl.js | 39 ++++++++++++++--------- server/controllers/memoCtrlHelpers.js | 1 + server/koppsApi.js | 12 ++----- server/ladokApi.js | 36 +++++++++++++++++++++ 8 files changed, 102 insertions(+), 34 deletions(-) create mode 100644 server/controllers/controllerFunctions.js create mode 100644 server/ladokApi.js diff --git a/package-lock.json b/package-lock.json index 11cb23b5..0165a7e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,6 +34,7 @@ "kth-node-i18n": "^1.0.18", "kth-node-redis": "^3.3.0", "kth-style": "^10.3.0", + "om-kursen-ladok-client": "file:../studadm-om-kursen-packages/packages/om-kursen-ladok-client", "react": "^18.2.0", "react-dom": "^18.2.0", "react-icons": "^4.12.0", @@ -82,6 +83,13 @@ "node": "18" } }, + "../studadm-om-kursen-packages/packages/om-kursen-ladok-client": { + "version": "0.0.1", + "dependencies": { + "ladok-attributvarde-utils": "file:../ladok-attributvarde-utils", + "ladok-mellanlager-client": "file:../ladok-mellanlager-client" + } + }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", @@ -13221,6 +13229,10 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/om-kursen-ladok-client": { + "resolved": "../studadm-om-kursen-packages/packages/om-kursen-ladok-client", + "link": true + }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", diff --git a/package.json b/package.json index ed8d39a5..a5687a80 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "kth-node-i18n": "^1.0.18", "kth-node-redis": "^3.3.0", "kth-style": "^10.3.0", + "om-kursen-ladok-client": "file:../studadm-om-kursen-packages/packages/om-kursen-ladok-client", "react": "^18.2.0", "react-dom": "^18.2.0", "react-icons": "^4.12.0", diff --git a/public/js/app/pages/AboutCourseMemo.jsx b/public/js/app/pages/AboutCourseMemo.jsx index 7b76ed3c..89d10d8c 100644 --- a/public/js/app/pages/AboutCourseMemo.jsx +++ b/public/js/app/pages/AboutCourseMemo.jsx @@ -217,18 +217,11 @@ function AboutCourseMemo({ mockKursPmDataApi = false, mockMixKoppsApi = false }) const [webContext] = useWebContext() - const { - allTypeMemos, - memoDatas, - courseCode, - language: userLangAbbr, - userLanguageIndex, - allRoundsFromKopps, - } = webContext + const { allTypeMemos, memoDatas, courseCode, language: userLangAbbr, userLanguageIndex, allRoundInfos } = webContext const isThisTest = !!mockKursPmDataApi - const [allRounds, setAllRounds] = useState(allRoundsFromKopps) + const [allRounds, setAllRounds] = useState(allRoundInfos) const webAndPdfMiniMemos = isThisTest ? mockKursPmDataApi : allTypeMemos const allRoundsMockOrReal = isThisTest ? mockMixKoppsApi : allRounds diff --git a/server/controllers/controllerFunctions.js b/server/controllers/controllerFunctions.js new file mode 100644 index 00000000..2c93d427 --- /dev/null +++ b/server/controllers/controllerFunctions.js @@ -0,0 +1,24 @@ +const createRoundInfos = (ladokRounds, koppsRoundInfos) => { + return ladokRounds.map(ladokRound => { + const { round: koppsRound } = koppsRoundInfos.find(roundInfo => roundInfo?.round?.ladokUID === ladokRound.uid) || {} + const { forstaUndervisningsdatum, sistaUndervisningsdatum, kortnamn, startperiod } = ladokRound + const { applicationCodes, shortName } = koppsRound || {} + return { + round: { + firstTuitionDate: forstaUndervisningsdatum.date, + lastTuitionDate: sistaUndervisningsdatum.date, + startWeek: forstaUndervisningsdatum, + endWeek: sistaUndervisningsdatum, + applicationCodes, + shortName: kortnamn || shortName, + startTerm: { + term: startperiod.code, + }, + }, + } + }) +} + +module.exports = { + createRoundInfos, +} diff --git a/server/controllers/memoCtrl.js b/server/controllers/memoCtrl.js index cba87a16..9b4cc0eb 100644 --- a/server/controllers/memoCtrl.js +++ b/server/controllers/memoCtrl.js @@ -11,6 +11,7 @@ const serverPaths = require('../server').getPaths() const { browser, server: serverConfig } = require('../configuration') const { getMemoDataById, getMemoVersion, getMiniMemosPdfAndWeb } = require('../kursPmDataApi') const { getDetailedInformation, getCourseRoundTerms } = require('../koppsApi') +const { getLadokCourseData, getActiveCourseRoundsByCourseCodeAndFromTerm } = require('../ladokApi') const { createBreadcrumbs } = require('../utils/breadcrumbUtil') const { getServerSideFunctions } = require('../utils/serverSideRendering') const { createServerSideContext } = require('../ssr-context/createServerSideContext') @@ -21,6 +22,7 @@ const { } = require('./memoCtrlHelpers') const { getLastYearsTerm, extractTerm } = require('../utils/term') const { redirectToAboutCourseConfig } = require('../utils/helpers') +const { createRoundInfos } = require('./controllerFunctions') const locales = { sv, en } @@ -200,11 +202,15 @@ async function getContent(req, res, next) { let fromTerm = semester ?? extractTerm(courseCode, finalMemoEndPoint) - const { title, credits, creditUnitAbbr, infoContactName, examiners, roundInfos } = await getDetailedInformation( - courseCode, - languagesContext.memoLanguage, - fromTerm - ) + const { title, credits, creditUnitAbbr } = await getLadokCourseData(courseCode, responseLanguage) + const ladokRounds = await getActiveCourseRoundsByCourseCodeAndFromTerm(courseCode, fromTerm, responseLanguage) + const { + infoContactName, + examiners, + roundInfos: koppsRoundInfos, + } = await getDetailedInformation(courseCode, languagesContext.memoLanguage, fromTerm) + + const roundInfos = createRoundInfos(ladokRounds, koppsRoundInfos) const courseContext = { title, @@ -324,10 +330,8 @@ async function getOldContent(req, res, next) { memoDatas: [], } - const { title, credits, creditUnitAbbr, infoContactName, examiners } = await getDetailedInformation( - courseCode, - languagesContext.memoLanguage - ) + const { title, credits, creditUnitAbbr } = await getLadokCourseData(courseCode) + const { infoContactName, examiners } = await getDetailedInformation(courseCode, languagesContext.memoLanguage) const courseContext = { title, @@ -411,11 +415,16 @@ async function getAboutContent(req, res, next) { const fromTerm = getLastYearsTerm() - const { title, credits, creditUnitAbbr, infoContactName, examiners, roundInfos } = await getDetailedInformation( - courseCode, - responseLanguage, - fromTerm - ) + const { title, credits, creditUnitAbbr } = await getLadokCourseData(courseCode, responseLanguage) + const ladokRounds = await getActiveCourseRoundsByCourseCodeAndFromTerm(courseCode, fromTerm, responseLanguage) + const { + infoContactName, + examiners, + roundInfos: koppsRoundInfos, + } = await getDetailedInformation(courseCode, responseLanguage, fromTerm) + + const roundInfos = createRoundInfos(ladokRounds, koppsRoundInfos) + webContext.title = title webContext.credits = credits webContext.creditUnitAbbr = creditUnitAbbr @@ -424,7 +433,7 @@ async function getAboutContent(req, res, next) { webContext.memoDatas = enrichMemoDatasWithOutdatedFlag(rawMemos, roundInfos) webContext.allTypeMemos = await getMiniMemosPdfAndWeb(courseCode) - webContext.allRoundsFromKopps = await _getAllRoundsWithApplicationCodes(roundInfos) + webContext.allRoundInfos = await _getAllRoundsWithApplicationCodes(roundInfos) // TODO: Proper language constant const shortDescription = (responseLanguage === 'sv' ? 'Om kursen ' : 'About course ') + courseCode diff --git a/server/controllers/memoCtrlHelpers.js b/server/controllers/memoCtrlHelpers.js index 57279541..6eed51fd 100644 --- a/server/controllers/memoCtrlHelpers.js +++ b/server/controllers/memoCtrlHelpers.js @@ -125,6 +125,7 @@ async function findMatchingRound(memo, roundInfos) { function lookForMatchingRoundInRoundInfos(semester, memoApplicationCodes, roundInfos) { const matchingRoundInfo = roundInfos.find(({ round: { applicationCodes } }) => { + if (!applicationCodes) return false const hasMatchingTermAndApplicationCode = applicationCodes.some(({ applicationCode, term }) => { return term === semester && memoApplicationCodes.includes(applicationCode) }) diff --git a/server/koppsApi.js b/server/koppsApi.js index d19c3969..7c868748 100644 --- a/server/koppsApi.js +++ b/server/koppsApi.js @@ -55,17 +55,9 @@ async function getDetailedInformation(courseCode, language, fromTerm) { try { const res = await client.getAsync({ uri, useCache: true }) if (res.body) { - const { course, examiners, roundInfos } = res.body - const isCreditNotStandard = - course && - course.credits && - course.credits.toString().indexOf('.') < 0 && - course.credits.toString().indexOf(',') < 0 + const { examiners, roundInfos } = res.body return { - title: course && course.title ? course.title : '', - credits: isCreditNotStandard ? course.credits + '.0' : course.credits || '', - creditUnitAbbr: course && course.creditUnitAbbr ? course.creditUnitAbbr : '', - infoContactName: course && course.infoContactName ? course.infoContactName : '', + infoContactName: '', examiners: createPersonHtml(examiners), roundInfos: roundInfos || [], } diff --git a/server/ladokApi.js b/server/ladokApi.js new file mode 100644 index 00000000..59a87fe4 --- /dev/null +++ b/server/ladokApi.js @@ -0,0 +1,36 @@ +'use strict' + +const { createApiClient } = require('om-kursen-ladok-client') +const serverConfig = require('./configuration').server + +async function getLadokCourseData(courseCode, lang) { + const client = createApiClient(serverConfig.ladokMellanlagerApi) + const course = await client.getLatestCourseVersion(courseCode, lang) + const { + benamning: ladokCourseTitle, + omfattning: ladokCourseCredits, + utbildningstyp: { creditsUnitCode: ladokCreditUnitAbbr }, + } = course + + const isCreditNotStandard = + ladokCourseCredits && + ladokCourseCredits.toString().indexOf('.') < 0 && + ladokCourseCredits.toString().indexOf(',') < 0 + + return { + title: ladokCourseTitle ?? '', + credits: isCreditNotStandard ? ladokCourseCredits + '.0' : ladokCourseCredits || '', + creditUnitAbbr: ladokCreditUnitAbbr ?? '', + } +} + +async function getActiveCourseRoundsByCourseCodeAndFromTerm(courseCode, fromTerm, lang) { + const client = createApiClient(serverConfig.ladokMellanlagerApi) + const rounds = await client.getActiveCourseRoundsFromTerm(courseCode, fromTerm, lang) + return rounds +} + +module.exports = { + getLadokCourseData, + getActiveCourseRoundsByCourseCodeAndFromTerm, +} From 667df20dbd4d5691a1dec68cc93a450d9c7cef66 Mon Sep 17 00:00:00 2001 From: amirhossein-haerian Date: Fri, 13 Sep 2024 12:56:07 +0200 Subject: [PATCH 3/5] remove one tiny thing --- test/mock-api/responses.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/mock-api/responses.js b/test/mock-api/responses.js index 1b5e665d..872e52e9 100644 --- a/test/mock-api/responses.js +++ b/test/mock-api/responses.js @@ -1116,7 +1116,6 @@ module.exports = { }, }, ], - // mainSubjects: ['Matematik', 'Teknik'], examinationSets: { 20072: { startingTerm: { From 8164f750421e283f13546f8b5fe7bdb55ce4ea8a Mon Sep 17 00:00:00 2001 From: amirhossein-haerian Date: Fri, 13 Sep 2024 14:19:18 +0200 Subject: [PATCH 4/5] fix(1425): the issue for showing semester wrongly is now fixed --- .../{controllerFunctions.js => helperFunctions.js} | 6 +++--- server/controllers/memoCtrl.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename server/controllers/{controllerFunctions.js => helperFunctions.js} (83%) diff --git a/server/controllers/controllerFunctions.js b/server/controllers/helperFunctions.js similarity index 83% rename from server/controllers/controllerFunctions.js rename to server/controllers/helperFunctions.js index 2c93d427..12371ac5 100644 --- a/server/controllers/controllerFunctions.js +++ b/server/controllers/helperFunctions.js @@ -2,7 +2,7 @@ const createRoundInfos = (ladokRounds, koppsRoundInfos) => { return ladokRounds.map(ladokRound => { const { round: koppsRound } = koppsRoundInfos.find(roundInfo => roundInfo?.round?.ladokUID === ladokRound.uid) || {} const { forstaUndervisningsdatum, sistaUndervisningsdatum, kortnamn, startperiod } = ladokRound - const { applicationCodes, shortName } = koppsRound || {} + const { applicationCodes } = koppsRound || {} return { round: { firstTuitionDate: forstaUndervisningsdatum.date, @@ -10,9 +10,9 @@ const createRoundInfos = (ladokRounds, koppsRoundInfos) => { startWeek: forstaUndervisningsdatum, endWeek: sistaUndervisningsdatum, applicationCodes, - shortName: kortnamn || shortName, + shortName: kortnamn, startTerm: { - term: startperiod.code, + term: startperiod.inDigits, }, }, } diff --git a/server/controllers/memoCtrl.js b/server/controllers/memoCtrl.js index 9b4cc0eb..a1163c51 100644 --- a/server/controllers/memoCtrl.js +++ b/server/controllers/memoCtrl.js @@ -22,7 +22,7 @@ const { } = require('./memoCtrlHelpers') const { getLastYearsTerm, extractTerm } = require('../utils/term') const { redirectToAboutCourseConfig } = require('../utils/helpers') -const { createRoundInfos } = require('./controllerFunctions') +const { createRoundInfos } = require('./helperFunctions') const locales = { sv, en } From fb34b470c0dc7632a598735d7815445d67bc6f1e Mon Sep 17 00:00:00 2001 From: amirhossein-haerian Date: Fri, 13 Sep 2024 15:03:27 +0200 Subject: [PATCH 5/5] get applicationCode from ladok --- server/controllers/helperFunctions.js | 9 ++++----- server/controllers/memoCtrl.js | 25 ++++++++++--------------- server/koppsApi.js | 3 +-- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/server/controllers/helperFunctions.js b/server/controllers/helperFunctions.js index 12371ac5..5e9a815d 100644 --- a/server/controllers/helperFunctions.js +++ b/server/controllers/helperFunctions.js @@ -1,15 +1,14 @@ -const createRoundInfos = (ladokRounds, koppsRoundInfos) => { +const createRoundInfos = ladokRounds => { return ladokRounds.map(ladokRound => { - const { round: koppsRound } = koppsRoundInfos.find(roundInfo => roundInfo?.round?.ladokUID === ladokRound.uid) || {} - const { forstaUndervisningsdatum, sistaUndervisningsdatum, kortnamn, startperiod } = ladokRound - const { applicationCodes } = koppsRound || {} + const { forstaUndervisningsdatum, sistaUndervisningsdatum, utbildningstillfalleskod, kortnamn, startperiod } = + ladokRound return { round: { firstTuitionDate: forstaUndervisningsdatum.date, lastTuitionDate: sistaUndervisningsdatum.date, startWeek: forstaUndervisningsdatum, endWeek: sistaUndervisningsdatum, - applicationCodes, + applicationCode: utbildningstillfalleskod, shortName: kortnamn, startTerm: { term: startperiod.inDigits, diff --git a/server/controllers/memoCtrl.js b/server/controllers/memoCtrl.js index a1163c51..e8e847ce 100644 --- a/server/controllers/memoCtrl.js +++ b/server/controllers/memoCtrl.js @@ -204,13 +204,13 @@ async function getContent(req, res, next) { const { title, credits, creditUnitAbbr } = await getLadokCourseData(courseCode, responseLanguage) const ladokRounds = await getActiveCourseRoundsByCourseCodeAndFromTerm(courseCode, fromTerm, responseLanguage) - const { - infoContactName, - examiners, - roundInfos: koppsRoundInfos, - } = await getDetailedInformation(courseCode, languagesContext.memoLanguage, fromTerm) + const { infoContactName, examiners } = await getDetailedInformation( + courseCode, + languagesContext.memoLanguage, + fromTerm + ) - const roundInfos = createRoundInfos(ladokRounds, koppsRoundInfos) + const roundInfos = createRoundInfos(ladokRounds) const courseContext = { title, @@ -417,13 +417,9 @@ async function getAboutContent(req, res, next) { const { title, credits, creditUnitAbbr } = await getLadokCourseData(courseCode, responseLanguage) const ladokRounds = await getActiveCourseRoundsByCourseCodeAndFromTerm(courseCode, fromTerm, responseLanguage) - const { - infoContactName, - examiners, - roundInfos: koppsRoundInfos, - } = await getDetailedInformation(courseCode, responseLanguage, fromTerm) + const { infoContactName, examiners } = await getDetailedInformation(courseCode, responseLanguage, fromTerm) - const roundInfos = createRoundInfos(ladokRounds, koppsRoundInfos) + const roundInfos = createRoundInfos(ladokRounds) webContext.title = title webContext.credits = credits @@ -536,12 +532,11 @@ async function _getAllRoundsWithApplicationCodes(roundInfos) { const allRounds = [] roundInfos.map(roundInfo => { const { round } = roundInfo - const { firstTuitionDate, lastTuitionDate, startTerm, applicationCodes } = round + const { firstTuitionDate, lastTuitionDate, startTerm, applicationCode } = round const { term } = startTerm if (isDateWithInCurrentOrFutureSemester(firstTuitionDate, lastTuitionDate)) { round.term = term - const { applicationCode = '' } = applicationCodes[0] - round.applicationCode = applicationCode + round.applicationCode = applicationCode || '' delete round.applicationCodes allRounds.push(round) } diff --git a/server/koppsApi.js b/server/koppsApi.js index 7c868748..acb7f46a 100644 --- a/server/koppsApi.js +++ b/server/koppsApi.js @@ -55,11 +55,10 @@ async function getDetailedInformation(courseCode, language, fromTerm) { try { const res = await client.getAsync({ uri, useCache: true }) if (res.body) { - const { examiners, roundInfos } = res.body + const { examiners } = res.body return { infoContactName: '', examiners: createPersonHtml(examiners), - roundInfos: roundInfos || [], } }