mirror of
https://github.com/UniversityOfHelsinkiCS/oodikone.git
synced 2026-10-12 19:03:39 +03:00
[Backend][statisticsOf] add course groupId to student credits
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Op } from 'sequelize'
|
||||
import { col, Op } from 'sequelize'
|
||||
|
||||
import { SISStudyRight, SISStudyRightElement, Student, Studyplan } from '@oodikone/shared/models'
|
||||
import { Tag, TagStudent } from '@oodikone/shared/models/kone'
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
StudyplanModel,
|
||||
SISStudyRightModel,
|
||||
SISStudyRightElementModel,
|
||||
CourseModel,
|
||||
} from '../../models'
|
||||
import { TagModel, TagStudentModel } from '../../models/kone'
|
||||
import { StudentCredit, StudentEnrollment } from '@oodikone/shared/types/studentData'
|
||||
@@ -190,11 +191,7 @@ export const getStudents = (studentNumbers: string[]): Promise<Array<StudentData
|
||||
},
|
||||
}).then(data => data.map(x => x.get({ plain: true })))
|
||||
|
||||
export const getCredits = async (
|
||||
studentNumbers: string[],
|
||||
startDate: string,
|
||||
endDate: string
|
||||
): Promise<StudentCredit[]> =>
|
||||
export const getCredits = async (studentNumbers: string[], startDate: string, endDate: string) =>
|
||||
CreditModel.findAll({
|
||||
raw: true,
|
||||
attributes: [
|
||||
@@ -208,12 +205,19 @@ export const getCredits = async (
|
||||
'course_code',
|
||||
'language',
|
||||
'studyright_id',
|
||||
[col('course.group_id'), 'courseGroupId'],
|
||||
],
|
||||
include: {
|
||||
model: CourseModel,
|
||||
attributes: [],
|
||||
as: 'course',
|
||||
required: true,
|
||||
},
|
||||
where: {
|
||||
student_studentnumber: { [Op.in]: studentNumbers },
|
||||
attainment_date: { [Op.between]: [startDate, endDate] },
|
||||
},
|
||||
})
|
||||
}) as unknown as Promise<StudentCredit[]>
|
||||
|
||||
export const getStudyRightElementsForStudyRight = async (studentNumbers: string[], code: string) =>
|
||||
SISStudyRightElementModel.findAll({
|
||||
|
||||
@@ -71,6 +71,7 @@ export const formatPopulationData = <T extends RequiredFields>(
|
||||
return {
|
||||
course_id: credit.course_id,
|
||||
course_code: credit.course_code,
|
||||
courseGroupId: credit.courseGroupId,
|
||||
date: credit.attainment_date,
|
||||
passed,
|
||||
grade: passed ? credit.grade : 'Hyl.',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Credit, Enrollment, SISStudyRight, SISStudyRightElement, Student, Studyplan } from '../models'
|
||||
import type { Course, Credit, Enrollment, SISStudyRight, SISStudyRightElement, Student, Studyplan } from '../models'
|
||||
import type { Tag, TagStudent } from '../models/kone'
|
||||
|
||||
import type { CriteriaYear, CreditTypeCode, Name, ProgrammeModule } from '../types'
|
||||
@@ -115,6 +115,7 @@ export type StudentCourse = {
|
||||
credittypecode: CreditTypeCode
|
||||
language: string
|
||||
studyright_id: string
|
||||
courseGroupId: Course['groupId']
|
||||
}
|
||||
|
||||
export type StudentCredit = Pick<
|
||||
@@ -129,7 +130,7 @@ export type StudentCredit = Pick<
|
||||
| 'course_code'
|
||||
| 'language'
|
||||
| 'studyright_id'
|
||||
>
|
||||
> & { courseGroupId: Course['groupId'] }
|
||||
|
||||
export type StudentEnrollment = Pick<
|
||||
Enrollment,
|
||||
|
||||
Reference in New Issue
Block a user