Skip to content

Commit

Permalink
[Faculties] Big refactor: Students and graduated of the faculty
Browse files Browse the repository at this point in the history
  • Loading branch information
valtterikantanen committed Jul 29, 2024
1 parent 2f5716c commit 9aa1bdf
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 598 deletions.
18 changes: 2 additions & 16 deletions services/backend/src/routes/faculties.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,9 @@ router.get('/:id/basicstats', auth.roles(['facultyStatistics', 'katselmusViewer'
const wantedProgrammes = await getProgrammes(code, programmeFilter)
if (!wantedProgrammes) return res.status(422).end()

// all programmes are required for correct sorting of transfers
const allProgrammeCodes = []
if (programmeFilter === 'NEW_STUDY_PROGRAMMES') {
const allProgs = await getProgrammes(code, 'ALL_PROGRAMMES')
allProgs?.data.forEach(prog => allProgrammeCodes.push(prog.code))
} else {
wantedProgrammes?.data.forEach(prog => allProgrammeCodes.push(prog.code))
}
const programmes = await getDegreeProgrammesOfFaculty(code, programmeFilter === 'NEW_STUDY_PROGRAMMES')

let updatedStats = await combineFacultyBasics(
code,
wantedProgrammes.data,
yearType,
allProgrammeCodes,
programmeFilter,
specialGroups
)
let updatedStats = await combineFacultyBasics(code, programmes, yearType, specialGroups)
if (updatedStats) {
updatedStats = await setBasicStats(updatedStats, yearType, programmeFilter, specialGroups)
}
Expand Down
37 changes: 0 additions & 37 deletions services/backend/src/services/faculty/faculty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,6 @@ import { getExtentFilter } from './facultyHelpers'

const { sequelize } = dbConnections

export const startedStudyrights = async (
facultyCode: string,
since: Date,
code: string,
includeAllSpecials: boolean
) => {
const studyRightWhere = getExtentFilter(includeAllSpecials)

const query = {
include: [
{
model: StudyrightElement,
required: true,
where: {
code,
},
include: [
{
model: ElementDetail,
required: true,
},
],
},
],
where: {
facultyCode,
startdate: {
[Op.gte]: since,
},
...studyRightWhere,
},
}

const studyRights = await Studyright.findAll(query)
return studyRights.map(formatFacultyStudyRight)
}

export const graduatedStudyrights = async (
facultyCode: string,
since: Date,
Expand Down
Loading

0 comments on commit 9aa1bdf

Please sign in to comment.