mirror of
https://github.com/UniversityOfHelsinkiCS/oodikone.git
synced 2026-10-12 19:03:39 +03:00
[CourseStats] Add better handling for invalid values
This commit is contained in:
committed by
Aaro Koivukangas
parent
25fb4bad84
commit
043b0d2cbd
@@ -60,7 +60,7 @@ router.get<never, CanError<CourseYearlyStatsResBody>, CourseYearlyStatsReqBody,
|
||||
|
||||
const courseCodes = handleQueryArrays(codes)
|
||||
|
||||
if (!courseCodes) {
|
||||
if (!courseCodes?.length) {
|
||||
return res.status(422).send({ error: 'Missing required query parameters' })
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,6 @@ export const getCreditsForCourses = async (codeGroups: string[][], unification:
|
||||
}
|
||||
}
|
||||
|
||||
// return completedGroups
|
||||
return completedGroups.filter(group => group.length)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Op, fn as dbFn, col as dbCol } from 'sequelize'
|
||||
import { Credit, Enrollment } from '@oodikone/shared/models'
|
||||
import { Name, EnrollmentState, Unification } from '@oodikone/shared/types'
|
||||
import { dateIsBetween } from '@oodikone/shared/util/datetime'
|
||||
import logger from '../../../src/util/logger'
|
||||
import { CourseModel, CreditModel, EnrollmentModel, OrganizationModel, SISStudyRightElementModel } from '../../models'
|
||||
import { isOpenUniCourseCode } from '../../util'
|
||||
import { CourseYearlyStatsCounter } from './courseYearlyStatsCounter'
|
||||
@@ -333,7 +334,8 @@ export const getCourseYearlyStats = async (
|
||||
})
|
||||
|
||||
if (!course) {
|
||||
return null
|
||||
logger.error('Course for course stats not found with code' + courseCode)
|
||||
return {}
|
||||
}
|
||||
|
||||
const [openStats, regularStats, unifyStats] = await Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user