Skip to content

Commit

Permalink
fix(haskolagatt): Remove obsolete program course code (#16604)
Browse files Browse the repository at this point in the history
* Dropping Course table and all code related to Program Course

* Cleanup

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
johannaagma and kodiakhq[bot] authored Oct 29, 2024
1 parent 10560f2 commit b86cd04
Show file tree
Hide file tree
Showing 28 changed files with 194 additions and 500 deletions.
2 changes: 1 addition & 1 deletion apps/services/university-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ yarn nx run services-university-gateway:codegen/backend-schema

### Worker

This service is for running scheduled tasks. Currently, fetching programs and courses from university APIs and adding data to out database.
This service is for running scheduled tasks. Currently, fetching programs from university APIs and adding data to out database.

## Running locally

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
'use strict'

module.exports = {
async up(queryInterface) {
return queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.dropTable('program_course', { transaction })
await queryInterface.dropTable('course', { transaction })
})
},

async down(queryInterface, Sequelize) {
return queryInterface.sequelize.transaction(async (t) => {
await queryInterface.createTable(
'course',
{
id: {
type: Sequelize.UUID,
primaryKey: true,
allowNull: false,
defaultValue: Sequelize.UUIDV4,
},
external_id: {
type: Sequelize.STRING,
allowNull: false,
},
name_is: {
type: Sequelize.STRING,
allowNull: false,
},
name_en: {
type: Sequelize.STRING,
allowNull: false,
},
university_id: {
type: Sequelize.UUID,
references: {
model: 'university',
key: 'id',
},
allowNull: false,
},
credits: {
type: Sequelize.FLOAT,
allowNull: false,
},
description_is: {
type: Sequelize.TEXT,
allowNull: true,
},
description_en: {
type: Sequelize.TEXT,
allowNull: true,
},
external_url_is: {
type: Sequelize.STRING(500),
allowNull: true,
},
external_url_en: {
type: Sequelize.STRING(500),
allowNull: true,
},
created: {
type: Sequelize.DATE,
allowNull: false,
},
modified: {
type: Sequelize.DATE,
allowNull: false,
},
},
{ transaction: t },
)

await queryInterface.createTable(
'program_course',
{
id: {
type: Sequelize.UUID,
primaryKey: true,
defaultValue: Sequelize.UUIDV4,
allowNull: false,
},
program_id: {
type: Sequelize.UUID,
references: {
model: 'program',
key: 'id',
},
allowNull: false,
},
course_id: {
type: Sequelize.UUID,
onDelete: 'CASCADE',
references: {
model: 'course',
key: 'id',
},
allowNull: false,
},
requirement: {
type: Sequelize.ENUM(
'MANDATORY',
'FREE_ELECTIVE',
'RESTRICTED_ELECTIVE',
),
allowNull: false,
},
semester_year: {
type: Sequelize.INTEGER,
allowNull: true,
},
semester_season: {
type: Sequelize.ENUM(
'FALL',
'SPRING',
'SUMMER',
'WHOLE_YEAR',
'ANY',
),
allowNull: false,
},
created: {
type: Sequelize.DATE,
allowNull: false,
},
modified: {
type: Sequelize.DATE,
allowNull: false,
},
},
{ transaction: t },
)
})
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ export class InternalProgramService {
specializationNameIs: specialization?.nameIs,
specializationNameEn: specialization?.nameEn,
universityId,
courses: [],
modeOfDelivery: [],
extraApplicationFields: [],
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class ProgramController {
@BypassAuth()
@Get('programs/:id')
@Documentation({
description: 'Get program (and courses) by ID',
description: 'Get program by ID',
response: {
status: 200,
type: Program,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class ProgramService {
'costInformationIs',
'costInformationEn',
'allowThirdLevelQualification',
'courses',
'extraApplicationFields',
],
},
Expand Down Expand Up @@ -154,7 +153,6 @@ export class ProgramService {
'costPerYear',
'iscedCode',
'tmpActive',
'courses',
],
},
include: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { environment } from '../../environments'
import { InternalProgramService } from '../modules/program/internalProgram.service'
import { InternalApplicationService } from '../modules/application/internalApplication.service'
import { University } from '../modules/university/model/university'
import { ProgramCourse } from '../modules/program/model/programCourse'
import { ProgramModeOfDelivery } from '../modules/program/model/programModeOfDelivery'
import { Program } from '../modules/program/model/program'
import { ProgramExtraApplicationField } from '../modules/program/model/programExtraApplicationField'
Expand All @@ -58,7 +57,6 @@ import { Application } from '../modules/application/model/application'
Program,
ProgramModeOfDelivery,
ProgramExtraApplicationField,
ProgramCourse,
Application,
]),
ReykjavikUniversityApplicationClientModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,48 +143,6 @@ export class UniversityGatewayProgramDetails extends UniversityGatewayProgram {
extraApplicationFields!: UniversityGatewayProgramExtraApplicationField[]
}

@ObjectType('UniversityGatewayProgramCourse')
class UniversityGatewayProgramCourse {
@Field()
id!: string

@Field()
externalId!: string

@Field()
nameIs!: string

@Field()
nameEn!: string

@Field()
credits!: number

@Field({ nullable: true })
semesterYear?: number

@Field({ nullable: true })
semesterYearNumber?: number

@Field()
semesterSeason!: string

@Field({ nullable: true })
descriptionIs?: string

@Field({ nullable: true })
descriptionEn?: string

@Field({ nullable: true })
externalUrlIs?: string

@Field({ nullable: true })
externalUrlEn?: string

@Field()
requirement!: string
}

@ObjectType('UniversityGatewayProgramExtraApplicationField')
class UniversityGatewayProgramExtraApplicationField {
@Field()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
import { Injectable } from '@nestjs/common'
import { CoursesApi, ProgramsApi } from '../../gen/fetch/apis'
import { ICourse, IProgram } from '@island.is/university-gateway'
import { ProgramsApi } from '../../gen/fetch/apis'
import { IProgram } from '@island.is/university-gateway'
import { logger } from '@island.is/logging'
import {
mapUglaPrograms,
mapUglaCourses,
} from '@island.is/clients/university-application/university-of-iceland'
import { mapUglaPrograms } from '@island.is/clients/university-application/university-of-iceland'

@Injectable()
export class AgriculturalUniversityOfIcelandApplicationClient {
constructor(
private readonly programsApi: ProgramsApi,
private readonly coursesApi: CoursesApi,
) {}
constructor(private readonly programsApi: ProgramsApi) {}

async getPrograms(): Promise<IProgram[]> {
const res = await this.programsApi.activeProgramsGet()

return mapUglaPrograms(res, 'agricultural-university-of-iceland')
}

async getCourses(programExternalId: string): Promise<ICourse[]> {
const res = await this.coursesApi.programExternalIdCoursesGet({
externalId: programExternalId,
// specializationExternalId // TODO missing in api
})

return mapUglaCourses(res, (courseExternalId: string, e: Error) => {
logger.error(
`Failed to map course with externalId ${courseExternalId} for program with externalId ${programExternalId} (agricultural-university-of-iceland), reason:`,
e,
)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
IdsClientConfig,
XRoadConfig,
} from '@island.is/nest/config'
import { Configuration, CoursesApi, ProgramsApi } from '../../gen/fetch'
import { Configuration, ProgramsApi } from '../../gen/fetch'
import { AgriculturalUniversityOfIcelandApplicationClientConfig } from './agriculturalUniversityOfIcelandClient.config'

const configFactory = (
Expand Down Expand Up @@ -35,7 +35,7 @@ const configFactory = (
basePath,
})

export const exportedApis = [ProgramsApi, CoursesApi].map((Api) => ({
export const exportedApis = [ProgramsApi].map((Api) => ({
provide: Api,
useFactory: (
xRoadConfig: ConfigType<typeof XRoadConfig>,
Expand Down
Loading

0 comments on commit b86cd04

Please sign in to comment.