diff --git a/services/backend/src/services/faculty/facultyThesisWriters.ts b/services/backend/src/services/faculty/facultyThesisWriters.ts index 705c4337fe..f2399f541d 100644 --- a/services/backend/src/services/faculty/facultyThesisWriters.ts +++ b/services/backend/src/services/faculty/facultyThesisWriters.ts @@ -73,11 +73,13 @@ const calculateCombinedStats = async ( const isMaster = degreeProgrammeType === degreeProgrammeTypes.master const correctIndex = isBachelor ? 0 : 1 - if (!combinedGraphStats[correctIndex].data) { - combinedGraphStats[correctIndex].data = [...thesisStats.data] - } else { - for (let i = 0; i < thesisStats.data.length; i++) { - combinedGraphStats[correctIndex].data[i] += thesisStats.data[i] + if (thesisStats) { + if (!combinedGraphStats[correctIndex].data) { + combinedGraphStats[correctIndex].data = [...thesisStats.data] + } else { + for (let i = 0; i < thesisStats.data.length; i++) { + combinedGraphStats[correctIndex].data[i] += thesisStats.data[i] + } } }