Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(KUI-1136): remove kursinfo-api dependency to this repository #386

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .azure/prod.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"APPLICATIONINSIGHTS_CONNECTION_STRING",
"KURSPLAN_API_KEY",
"KURSPLAN_API_URI",
"KURSINFO_API_KEY",
"KURS_PM_DATA_API_KEY",
"REDIS_URI",
"SESSION_KEY",
Expand All @@ -22,9 +21,7 @@
"CAS_SSO_URI": "https://login.kth.se",
"CM_HOST_URL": "https://www.kth.se/cm/",
"CONSOLE_ENABLED": "false",
"IMAGE_STORAGE_URI": "https://kursinfostorageprod.blob.core.windows.net/kursinfo-image-container/",
"KOPPS_URI": "https://api.kth.se/api/kopps/v2/?defaultTimeout=60000",
"KURSINFO_API_URI": "https://api.kth.se/api/kursinfo?defaultTimeout=10000",
"KURS_PM_DATA_API_URI": "https://api.kth.se/api/kurs-pm-data?defaultTimeout=10000",
"LOGGING_ACCESS_LOG": "true",
"LOGGING_LEVEL": "INFO",
Expand Down
4 changes: 1 addition & 3 deletions .azure/ref.parameters.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that we have a MEMO_STORAGE_URI in prod.parameters.json, but not in ref.parameters.json.
I'm wondering right now - how does this actually work in REF? Because PDFs work in ref, but how? Where do we get the correct link from? Do we run the app in REF with the dev or development environment set in node?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, the correct fast way would be to add the parameter in ref.parameters as well (obviously the one pointing to REF)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a really good point, it was my question as well. So inside commonSetting.js we are setting devMemoStorageUri.
const devMemoStorageUri = 'https://kursinfostoragestage.blob.core.windows.net/memo-blob-container/'

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"APPLICATIONINSIGHTS_CONNECTION_STRING",
"KURSPLAN_API_KEY",
"KURSPLAN_API_URI",
"KURSINFO_API_KEY",
"KURS_PM_DATA_API_KEY",
"REDIS_URI",
"SESSION_KEY",
Expand All @@ -22,12 +21,11 @@
"CAS_SSO_URI": "https://login-r.referens.sys.kth.se",
"CM_HOST_URL": "https://www-r.referens.sys.kth.se/cm/",
"CONSOLE_LOG": "true",
"IMAGE_STORAGE_URI": "https://kursinfostoragestage.blob.core.windows.net/kursinfo-image-container/",
"KOPPS_URI": "https://api-r.referens.sys.kth.se/api/kopps/v2/?defaultTimeout=60000",
"KURSINFO_API_URI": "https://app-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000",
"KURS_PM_DATA_API_URI": "https://api-r.referens.sys.kth.se/api/kurs-pm-data?defaultTimeout=10000",
"LOGGING_ACCESS_LOG": "true",
"LOGGING_LEVEL": "TRACE",
"MEMO_STORAGE_URI": "https://kursinfostoragestage.blob.core.windows.net/memo-blob-container/",
"SERVER_HOST_URL": "https://www-r.referens.sys.kth.se",
"SERVER_PORT": "3000",
"SERVICE_PUBLISH": "/kurs-pm",
Expand Down
1 change: 0 additions & 1 deletion .env.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
KURS_PM_DATA_API_KEY=[Available in Azure KeyVault]
KURSINFO_API_KEY=[Available in Azure KeyVault]
KURSPLAN_API_KEY=[Available in Azure KeyVault]

REDIS_URI=[Available in Azure KeyVault]
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ Kurs-pm-web is a microservice with the public view of course memos. It uses [Rea
Kurs-pm-web fetches data from:

- Course memo API `/api/kurs-pm-data`
- Course information API `/api/kursinfo`
- API to store information about course syllabuses `/api/kursplan`
- API för kurs- och programinformation `/api/kopps/v2/`

### Related projects

- [kurs-pm-data-admin-web](https://github.com/KTH/kurs-pm-data-admin-web)
- [kurs-pm-data-api](https://github.com/KTH/kurs-pm-data-api)
- [kursinfo-api](https://github.com/KTH/kursinfo-api)
- [kursplan-api](https://github.com/KTH/kursplan-api)
- [node-web](https://github.com/KTH/node-web)

Expand Down
4 changes: 1 addition & 3 deletions config/commonSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
const { getEnv, devDefaults } = require('kth-node-configuration')

const devPrefixPath = devDefaults('/kurs-pm')
const devImageStorageUri = devDefaults('https://kursinfostoragestage.blob.core.windows.net/kursinfo-image-container/')
const devMemoStorageUri = 'https://kursinfostoragestage.blob.core.windows.net/memo-blob-container/'
const devMemoStorageUri = devDefaults('https://kursinfostoragestage.blob.core.windows.net/memo-blob-container/')

module.exports = {
// The proxy prefix path if the application is proxied. E.g /places
proxyPrefixPath: {
uri: getEnv('SERVICE_PUBLISH', devPrefixPath),
},
imageStorageUri: getEnv('IMAGE_STORAGE_URI', devImageStorageUri),
memoStorageUri: getEnv('MEMO_STORAGE_URI', devMemoStorageUri),
}
3 changes: 0 additions & 3 deletions config/serverSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const devPort = devDefaults(3000)
const devSsl = devDefaults(false)
const devUrl = devDefaults('http://localhost:' + devPort)
const devKursPmDataApi = devDefaults('https://api-r.referens.sys.kth.se/api/kurs-pm-data?defaultTimeout=10000')
const devKursInfoApi = devDefaults('https://api-r.referens.sys.kth.se/api/kursinfo?defaultTimeout=10000')
const devKursplanApi = devDefaults('https://api-r.referens.sys.kth.se/api/kursplan?defaultTimeout=10000')
const devKoppsApi = devDefaults('https://api-r.referens.sys.kth.se/api/kopps/v2/?defaultTimeout=10000')
const devSessionKey = devDefaults('kurs-pm-web.sid')
Expand All @@ -41,14 +40,12 @@ module.exports = {
// API keys
apiKey: {
kursPmDataApi: getEnv('KURS_PM_DATA_API_KEY', devDefaults('1234')),
kursInfoApi: getEnv('KURSINFO_API_KEY', devDefaults('1234')),
kursplanApi: getEnv('KURSPLAN_API_KEY', devDefaults('5678')),
},

// Service API's
nodeApi: {
kursPmDataApi: unpackNodeApiConfig('KURS_PM_DATA_API_URI', devKursPmDataApi),
kursInfoApi: unpackNodeApiConfig('KURSINFO_API_URI', devKursInfoApi),
kursplanApi: unpackNodeApiConfig('KURSPLAN_API_URI', devKursplanApi),
},

Expand Down
2 changes: 0 additions & 2 deletions docker-compose-integration-tests-old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ services:
- LOGGING_ACCESS_LOG=true
- KURS_PM_DATA_API_URI=http://mock-api:3000/kurs-pm
- KURS_PM_DATA_API_KEY=secretpassword
- KURSINFO_API_URI=http://mock-api:3000/kursinfo
- KURSINFO_API_KEY=secretpassword
- KURSPLAN_API_URI=http://mock-api:3000/kursplan
- KURSPLAN_API_KEY=secretpassword
- REDIS_URI=redis://redis:6379
Expand Down
2 changes: 0 additions & 2 deletions docker-compose-performance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ services:
LOGGING_ACCESS_LOG: 'false'
KURS_PM_DATA_API_URI: 'http://mock-api:3000/kurs-pm'
KURS_PM_DATA_API_KEY: 'secretpassword'
KURSINFO_API_URI: 'http://mock-api:3000/kursinfo'
KURSINFO_API_KEY: 'secretpassword'
KURSPLAN_API_URI: 'http://mock-api:3000/kursplan'
KURSPLAN_API_KEY: 'secretpassword'
REDIS_URI: 'redis://redis:6379'
Expand Down
29 changes: 0 additions & 29 deletions i18n/messages.en.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,6 @@ module.exports = {
default: 'default',
},

courseImage: {
Architecture: 'Picture_by_MainFieldOfStudy_01_Architecture.jpg',
Biotechnology: 'Picture_by_MainFieldOfStudy_02_Biotechnology.jpg',
'Computer Science and Engineering': 'Picture_by_MainFieldOfStudy_03_Computer_Science.jpg',
'Electrical Engineering': 'Picture_by_MainFieldOfStudy_04_Electrical_Engineering.jpg',
Physics: 'Picture_by_MainFieldOfStudy_05_Physics.jpg',
'Industrial Management': 'Picture_by_MainFieldOfStudy_06_Industrial_Management.jpg',
'Information Technology': 'Picture_by_MainFieldOfStudy_07_Information_Technology.jpg',
'Information and Communication Technology': 'Picture_by_MainFieldOfStudy_08_Information_Communication.jpg',
'Chemical Science and Engineering': 'Picture_by_MainFieldOfStudy_09_Chemical_Science.jpg',
'Chemistry and Chemical Engineering': 'Picture_by_MainFieldOfStudy_10_Chemistry_Chemical.jpg',
Mathematics: 'Picture_by_MainFieldOfStudy_11_Mathematics.jpg',
'Environmental Engineering': 'Picture_by_MainFieldOfStudy_12_Environmental_Engineering.jpg',
'Molecular Life Science': 'Picture_by_MainFieldOfStudy_13_Molecular_Life_Science.jpg',
'Mechanical Engineering': 'Picture_by_MainFieldOfStudy_14_Mechanical_Engineering.jpg',
'Materials Science': 'Picture_by_MainFieldOfStudy_15_Materials_Science.jpg',
'Medical Engineering': 'Picture_by_MainFieldOfStudy_16_Medical_Engineering.jpg',
'Materials Science and Engineering': 'Picture_by_MainFieldOfStudy_17_Materials_Engineering.jpg',
'Built Environment': 'Picture_by_MainFieldOfStudy_18_Built_Environment.jpg',
'Engineering Physics': 'Picture_by_MainFieldOfStudy_19_Engineering_Physics.jpg',
'Technology and Economics': 'Picture_by_MainFieldOfStudy_20_Technology_Economics.jpg',
'Technology and Health': 'Picture_by_MainFieldOfStudy_21_Technology_Health.jpg',
'Technology and Management': 'Picture_by_MainFieldOfStudy_22_Technology_Management.jpg',
Technology: 'Picture_by_MainFieldOfStudy_23_Technology.jpg',
'Engineering and Management': 'Picture_by_MainFieldOfStudy_24_Engineering_Management.jpg',
'Technology and Learning': 'Picture_by_MainFieldOfStudy_25_Technology_Learning.jpg',
default: 'Picture_by_MainFieldOfStudy_26_Default_picture.jpg',
},

courseInformationTitle: 'Information',

adminLinkLabel: 'Administer About course',
Expand Down
28 changes: 0 additions & 28 deletions i18n/messages.se.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,6 @@ module.exports = {

mandatoryFieldMissing: 'Obligatoriskt innehåll saknas',

courseImage: {
Arkitektur: 'Picture_by_MainFieldOfStudy_01_Architecture.jpg',
Bioteknik: 'Picture_by_MainFieldOfStudy_02_Biotechnology.jpg',
'Datalogi och datateknik': 'Picture_by_MainFieldOfStudy_03_Computer_Science.jpg',
Elektroteknik: 'Picture_by_MainFieldOfStudy_04_Electrical_Engineering.jpg',
Fysik: 'Picture_by_MainFieldOfStudy_05_Physics.jpg',
'Industriell ekonomi': 'Picture_by_MainFieldOfStudy_06_Industrial_Management.jpg',
Informationsteknik: 'Picture_by_MainFieldOfStudy_07_Information_Technology.jpg',
'Informations- och kommunikationsteknik': 'Picture_by_MainFieldOfStudy_08_Information_Communication.jpg',
Kemiteknik: 'Picture_by_MainFieldOfStudy_09_Chemical_Science.jpg',
'Kemi och kemiteknik': 'Picture_by_MainFieldOfStudy_10_Chemistry_Chemical.jpg',
Matematik: 'Picture_by_MainFieldOfStudy_11_Mathematics.jpg',
Miljöteknik: 'Picture_by_MainFieldOfStudy_12_Environmental_Engineering.jpg',
'Molekylära livsvetenskaper': 'Picture_by_MainFieldOfStudy_13_Molecular_Life_Science.jpg',
Maskinteknik: 'Picture_by_MainFieldOfStudy_14_Mechanical_Engineering.jpg',
Materialvetenskap: 'Picture_by_MainFieldOfStudy_15_Materials_Science.jpg',
'Medicinsk teknik': 'Picture_by_MainFieldOfStudy_16_Medical_Engineering.jpg',
Materialteknik: 'Picture_by_MainFieldOfStudy_17_Materials_Engineering.jpg',
Samhällsbyggnad: 'Picture_by_MainFieldOfStudy_18_Built_Environment.jpg',
'Teknisk fysik': 'Picture_by_MainFieldOfStudy_19_Engineering_Physics.jpg',
'Teknik och ekonomi': 'Picture_by_MainFieldOfStudy_20_Technology_Economics.jpg',
'Teknik och hälsa': 'Picture_by_MainFieldOfStudy_21_Technology_Health.jpg',
'Teknik och management': 'Picture_by_MainFieldOfStudy_22_Technology_Management.jpg',
Teknik: 'Picture_by_MainFieldOfStudy_23_Technology.jpg',
'Teknik och lärande': 'Picture_by_MainFieldOfStudy_25_Technology_Learning.jpg',
default: 'Picture_by_MainFieldOfStudy_26_Default_picture.jpg',
},

courseInformationTitle: 'Information',

adminLinkLabel: 'Administrera Om kursen',
Expand Down
4 changes: 0 additions & 4 deletions public/js/app/pages/CourseMemo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Row, Col } from 'reactstrap'
import i18n from '../../../../i18n'
import { concatMemoName, memoNameWithoutApplicationCode, seasonStr, formatCredits } from '../util/helpers'
import { sideMenuBackLink } from '../util/links'
import { resolveCourseImage } from '../util/course-image'
import { menuItemsForCurrentMemo } from '../util/menu-memo-items'

import { useWebContext } from '../context/WebContext'
Expand Down Expand Up @@ -116,8 +115,6 @@ function CourseMemo() {
return () => (isMounted = false)
}, [])

const courseImage = resolveCourseImage(webContext.imageFromAdmin, webContext.courseMainSubjects, memoLanguage)
const courseImageUrl = `${webContext.browserConfig.imageStorageUri}${courseImage}`
const memoLanguageIndex = getLangIndex(memoLanguage)
const courseTitle = `${courseCode} ${title} ${formatCredits(credits, creditUnitAbbr, language)}`

Expand Down Expand Up @@ -206,7 +203,6 @@ function CourseMemo() {
outdatedMemo={isMemoOutdated()}
latestMemoLabel={webContext.latestMemoLabel}
latestMemoUrl={latestMemoUrl}
courseImageUrl={courseImageUrl}
/>
<Row>
<Col id="flexible-content-of-center" lg="8" className="text-break col-print-12 content-center">
Expand Down
2 changes: 1 addition & 1 deletion public/js/app/pages/__tests__/AboutCourseMemoEN.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('User language: English. Component <AboutCourseMemo> show all memos: pd
beforeEach(() => {
const context = {
courseCode: 'KIP2720',
browserConfig: { imageStorageUri: 'localhost://', memoStorageUri: 'kursinfostorage/' },
browserConfig: { memoStorageUri: 'kursinfostorage/' },
memoData: {
courseTitle: 'KIP2720 Projektstyrning 7,5 hp',
visibleInMemo: {},
Expand Down
2 changes: 1 addition & 1 deletion public/js/app/pages/__tests__/AboutCourseMemoSV.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('User language: Swedish. Component <AboutCourseMemo> show all memos: pd
beforeEach(() => {
const context = {
courseCode: 'KIP2720',
browserConfig: { imageStorageUri: 'localhost://', memoStorageUri: 'kursinfostorage/' },
browserConfig: { memoStorageUri: 'kursinfostorage/' },
memoData: {
courseTitle: 'KIP2720 Projektstyrning 7,5 hp',
visibleInMemo: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const renderWithOptions = (memoDatas, languageSetting, applicationCodes = []) =>
}

const context = {
browserConfig: { imageStorageUri: 'localhost://', memoStorageUri: 'kursinfostorage/' },
browserConfig: { memoStorageUri: 'kursinfostorage/' },
memoData: {
courseTitle: 'DD2380 Artificiell intelligens 6.0 hp',
visibleInMemo: {},
Expand Down
6 changes: 3 additions & 3 deletions public/js/app/pages/__tests__/CourseMemo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Redirect function in <CourseMemo>', () => {
describe('Component <CourseMemo>', () => {
test('renders a course memo', () => {
const context = {
browserConfig: { imageStorageUri: 'localhost://' },
browserConfig: {},
memoData: {
courseTitle: '',
visibleInMemo: {},
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('Page CourseMemo', () => {
test('renders a side menu and a page structure', done => {
const memoDatas = [spring181, spring1823, spring184, spring1924, spring193, fall190]
const context = {
browserConfig: { imageStorageUri: 'localhost://' },
browserConfig: {},
memoData: { ...spring181, courseTitle: '', visibleInMemo: {} },
memoDatas,
memoLanguageIndex: 0,
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('Page CourseMemo', () => {
test('renders a side menu links', done => {
const memoDatas = [spring181, spring1823, spring184, spring1924, spring193, fall190]
const context = {
browserConfig: { imageStorageUri: 'localhost://' },
browserConfig: {},
memoData: { ...spring181, courseTitle: '', visibleInMemo: {} },
memoDatas,
memoLanguageIndex: 0,
Expand Down
2 changes: 1 addition & 1 deletion public/js/app/pages/__tests__/noCourseMemo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CourseMemo from '../CourseMemo'
describe('User language: Swedish. Component <CourseMemo> renders <AboutCourseMemo> because no memo exists for some round, f.e., semester 20192, applicationCodes 2', () => {
beforeEach(() => {
const context = {
browserConfig: { imageStorageUri: 'localhost://', memoStorageUri: 'kursinfostorage/' },
browserConfig: { memoStorageUri: 'kursinfostorage/' },
memoData: {
courseTitle: 'KIP2720 Projektstyrning 7,5 hp',
visibleInMemo: {},
Expand Down
28 changes: 0 additions & 28 deletions public/js/app/util/course-image.js

This file was deleted.

1 change: 0 additions & 1 deletion server/controllers/__tests__/memoCtrlHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ jest.mock('../../kursPmDataApi', () => ({
getMemoDataById: () => {},
getMiniMemosPdfAndWeb: () => {},
}))
jest.mock('../../kursInfoApi', () => ({ getCourseInfo: () => {} }))

jest.mock('@kth/log', () => ({ error: jest.fn(), debug: jest.fn }))

Expand Down
19 changes: 0 additions & 19 deletions server/controllers/memoCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const apis = require('../api')
const serverPaths = require('../server').getPaths()
const { browser, server: serverConfig } = require('../configuration')
const { getMemoDataById, getMemoVersion, getMiniMemosPdfAndWeb } = require('../kursPmDataApi')
const { getCourseInfo } = require('../kursInfoApi')
const { getDetailedInformation, getCourseRoundTerms } = require('../koppsApi')
const { createBreadcrumbs } = require('../utils/breadcrumbUtil')
const { getServerSideFunctions } = require('../utils/serverSideRendering')
Expand Down Expand Up @@ -139,10 +138,6 @@ function resolveMemoEndPoint(potentialMemoEndPoint, memoDatas) {
return memoDatas[0] ? memoDatas[0].memoEndPoint : ''
}

function resolveSellingText(sellingText = {}, recruitmentText, lang) {
return sellingText[lang] ? sellingText[lang] : recruitmentText
}

function resolveLatestMemoLanguage(latestMemoDatas) {
return latestMemoDatas ? latestMemoDatas.memoCommonLangAbbr : null
}
Expand Down Expand Up @@ -242,17 +237,10 @@ async function getContent(req, res, next) {
semester: semester || memoWithExtraProps?.semester,
}

const { sellingText, imageInfo } = await getCourseInfo(courseCode)
const courseIntroductionContext = {
sellingText: resolveSellingText(sellingText, recruitmentText, languagesContext.memoLanguage),
imageFromAdmin: imageInfo,
}

const shortDescription = (responseLanguage === 'sv' ? 'Om kursen ' : 'About course ') + courseCode

const webContext = {
...rawContext, // always first
...courseIntroductionContext,
...languagesContext,
...courseContext,
...memoContext,
Expand Down Expand Up @@ -354,17 +342,10 @@ async function getOldContent(req, res, next) {
examiners,
}

const { sellingText, imageInfo } = await getCourseInfo(courseCode)
const courseIntroductionContext = {
sellingText: resolveSellingText(sellingText, recruitmentText, languagesContext.memoLanguage),
imageFromAdmin: imageInfo,
}

const shortDescription = (responseLanguage === 'sv' ? 'Om kursen ' : 'About course ') + courseCode

const webContext = {
...rawContext, // always first
...courseIntroductionContext,
...languagesContext,
...courseContext,
...memoContext,
Expand Down
25 changes: 0 additions & 25 deletions server/kursInfoApi.js

This file was deleted.

Loading
Loading