diff --git a/services/backend/src/services/courses/courseYearlyStatsCounter.ts b/services/backend/src/services/courses/courseYearlyStatsCounter.ts index 3b836ab94d..d36270f202 100644 --- a/services/backend/src/services/courses/courseYearlyStatsCounter.ts +++ b/services/backend/src/services/courses/courseYearlyStatsCounter.ts @@ -1,4 +1,4 @@ -import { EnrollmentState, Name } from '../../types' +import { Name } from '../../types' import { FormattedProgramme, OrganizationDetails } from './helpers' type Programme = { @@ -49,8 +49,8 @@ type Group = { coursecode: string attempts: GroupAttempts students: GroupStudents - enrollments: { studentNumber: string; state: string; enrollmentDateTime: Date }[] - allEnrollments: { studentNumber: string; state: string; enrollmentDateTime: Date }[] + enrollments: { studentNumber: string; enrollmentDateTime: Date }[] + allEnrollments: { studentNumber: string; enrollmentDateTime: Date }[] yearcode: number } @@ -211,7 +211,6 @@ export class CourseYearlyStatsCounter { public markEnrollmentToGroup( studentNumber: string, - state: string, enrollmentDateTime: Date, groupCode: number, groupName: string | Name, @@ -221,22 +220,13 @@ export class CourseYearlyStatsCounter { if (!this.groups[groupCode]) { this.initGroup(groupCode, groupName, courseCode, yearCode) } - const enrollment = { studentNumber, state, enrollmentDateTime } + const enrollment = { studentNumber, enrollmentDateTime } this.groups[groupCode].allEnrollments.push(enrollment) const oldEnrollment = this.groups[groupCode].enrollments.find( enrollment => enrollment.studentNumber === studentNumber ) if (!oldEnrollment) { - return this.groups[groupCode].enrollments.push({ studentNumber, state, enrollmentDateTime }) - } - if (oldEnrollment.state === EnrollmentState.ENROLLED || oldEnrollment.state === EnrollmentState.CONFIRMED) { - return - } - if (state !== EnrollmentState.ENROLLED && state !== EnrollmentState.CONFIRMED) { - return - } - if (![EnrollmentState.ENROLLED, EnrollmentState.CONFIRMED].includes(state as EnrollmentState)) { - return + return this.groups[groupCode].enrollments.push({ studentNumber, enrollmentDateTime }) } this.groups[groupCode].enrollments = this.groups[groupCode].enrollments .filter(enrollment => enrollment.studentNumber !== studentNumber) diff --git a/services/backend/src/services/courses/creditsAndEnrollmentsOfCourse.ts b/services/backend/src/services/courses/creditsAndEnrollmentsOfCourse.ts index 3a898a518d..e710d198e8 100644 --- a/services/backend/src/services/courses/creditsAndEnrollmentsOfCourse.ts +++ b/services/backend/src/services/courses/creditsAndEnrollmentsOfCourse.ts @@ -95,7 +95,7 @@ export const getEnrollmentsForCourses = async (codes: string[], unification: Uni [Op.in]: codes, }, enrollment_date_time: { [Op.gte]: new Date('2021-05-31') }, - state: [EnrollmentState.ENROLLED, EnrollmentState.CONFIRMED], + state: EnrollmentState.ENROLLED, is_open: getIsOpen(unification), }, }) diff --git a/services/backend/src/services/courses/index.ts b/services/backend/src/services/courses/index.ts index 30c902342c..beb5a5ea83 100644 --- a/services/backend/src/services/courses/index.ts +++ b/services/backend/src/services/courses/index.ts @@ -99,7 +99,6 @@ type FormattedEnrollment = { semesterCode: number semesterName: Name courseCode: string - state: string enrollmentDateTime: Date studentNumber: string programmes: Array> @@ -114,7 +113,6 @@ const parseEnrollment = ( const { studentnumber: studentNumber, semester, - state, enrollment_date_time: enrollmentDateTime, course_code: courseCode, } = enrollment @@ -128,7 +126,6 @@ const parseEnrollment = ( semesterCode, semesterName, courseCode, - state, enrollmentDateTime, studentNumber, programmes: studyRightElements.map(formatStudyRightElement), @@ -222,13 +219,13 @@ const getYearlyStatsOfNew = async ( } enrollments.forEach(enrollment => { - const { studentNumber, semesterCode, semesterName, yearCode, yearName, courseCode, state, enrollmentDateTime } = + const { studentNumber, semesterCode, semesterName, yearCode, yearName, courseCode, enrollmentDateTime } = parseEnrollment(enrollment, anonymizationSalt, studentNumberToSrElementsMap) const groupCode = separate ? semesterCode : yearCode const groupName = separate ? semesterName : yearName - counter.markEnrollmentToGroup(studentNumber, state, enrollmentDateTime, groupCode, groupName, courseCode, yearCode) + counter.markEnrollmentToGroup(studentNumber, enrollmentDateTime, groupCode, groupName, courseCode, yearCode) }) const statistics = counter.getFinalStatistics(anonymizationSalt)