Skip to content

Commit

Permalink
feat: upgraded name logic for the course realisations
Browse files Browse the repository at this point in the history
  • Loading branch information
HRemonen committed May 17, 2024
1 parent f61dcbc commit 0e3d9c2
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { parseFromTimeZone } = require("date-fns-timezone")
const dateFns = require('date-fns')
const { CourseRealisation, CourseRealisationsOrganisation, InactiveCourseRealisation } = require("../../models")
const { safeBulkCreate } = require("../util")
const { formatWithHours } = require("./utils")
const { formatWithHours, formatCourseName } = require("./utils")
const logger = require("../../util/logger")

const getCourseRealisationPeriod = (activityPeriod) => {
Expand Down Expand Up @@ -91,13 +91,21 @@ const createCourseRealisations = async (courseRealisations) => {
for (const {
id,
name,
nameSpecifier,
activityPeriod,
organisations,
customCodeUrns,
} of courseRealisations) {

const courseRealisationName = {
fi: formatCourseName(id, name, nameSpecifier, 'fi'),
en: formatCourseName(id, name, nameSpecifier, 'en'),
sv: formatCourseName(id, name, nameSpecifier, 'sv'),
}

await CourseRealisation.upsert({
id,
name,
name: courseRealisationName,
...getCourseRealisationPeriod(activityPeriod),
educationalInstitutionUrn: getEducationalInstitutionUrn(organisations),
isMoocCourse: isMoocCourse(customCodeUrns),
Expand Down

0 comments on commit 0e3d9c2

Please sign in to comment.