diff --git a/app/api/graduations/list/func.js b/app/api/graduations/list/func.js index 8676f6c..804a223 100644 --- a/app/api/graduations/list/func.js +++ b/app/api/graduations/list/func.js @@ -28,7 +28,6 @@ module.exports = async function func() { ).reduce((acc, subject) => { const category = subject.category if (!category) { - console.log('no category', subject) return acc } if (!acc[category]) { diff --git a/app/api/graduations/stats/func.js b/app/api/graduations/stats/func.js index ca5032f..4535ab5 100644 --- a/app/api/graduations/stats/func.js +++ b/app/api/graduations/stats/func.js @@ -32,7 +32,6 @@ module.exports = async function func(context) { ).reduce((acc, subject) => { const category = subject.category if (!category) { - console.log('no category', subject) return acc } if (!acc[category]) { @@ -72,12 +71,7 @@ module.exports = async function func(context) { const mandatories = populatedGraduation.subjects.mandatory.filter( (subject) => { return enrollments.some((enrollment) => { - if (!enrollment.subject) { - console.log('no subject', enrollment) - return false - } - if (!subject.subject) { - console.log('no subject', subject) + if (!enrollment.subject || !subject.subject) { return false } return ( @@ -89,12 +83,7 @@ module.exports = async function func(context) { const limited = populatedGraduation.subjects.limited.filter((subject) => { return enrollments.some((enrollment) => { - if (!enrollment.subject) { - console.log('no subject', enrollment) - return false - } - if (!subject.subject) { - console.log('no subject', subject) + if (!enrollment.subject || !subject.subject) { return false } return ( @@ -103,6 +92,8 @@ module.exports = async function func(context) { }) }) + const invalidGrades = ['O', 'F'] + return { percentage: { mandatories: @@ -128,6 +119,9 @@ module.exports = async function func(context) { missing: { mandatories: populatedGraduation.subjects.mandatory.filter((subject) => { return !mandatories.some((enrollment) => { + const completed = !invalidGrades.includes(enrollment.conceito) + if (!completed) return false + return ( enrollment.subject._id.toString() === subject.subject._id.toString() ) @@ -135,6 +129,9 @@ module.exports = async function func(context) { }), limited: populatedGraduation.subjects.limited.filter((subject) => { return !limited.some((enrollment) => { + const completed = !invalidGrades.includes(enrollment.conceito) + if (!completed) return false + return ( enrollment.subject._id.toString() === subject.subject._id.toString() )