-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
128 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export function computeFulfillmentStats(groups : readonly GroupedRequirementFulfillmentReport[], idRequirementFrequency : Map<string, Map<number, number>[]>) { | ||
let res = idRequirementFrequency; | ||
groups.forEach(currentGroup => { | ||
const { reqs } = currentGroup; | ||
reqs.forEach(reqFulfillment => { | ||
let current = []; | ||
const key: string = reqFulfillment.requirement.id; | ||
const { safeCourses } = reqFulfillment.fulfillment; | ||
|
||
// Obtain the frequency list for this particular group's requirements | ||
let freqList = res.get(key) ?? []; | ||
|
||
// Iterate over all slots in the requirement group | ||
// console.log(safeCourses.length); | ||
for (let slotNumber = 0; slotNumber < safeCourses.length; slotNumber += 1) { | ||
if (freqList.length === slotNumber) { | ||
freqList.push(new Map<number, number>()); | ||
} | ||
const currentCourseSlot = safeCourses[slotNumber]; | ||
const currentRequirementSlotFreq = freqList[slotNumber]; | ||
|
||
// Iterate over all courses taken to fulfill the req-slot | ||
for (let j = 0; j < currentCourseSlot.length; j += 1) { | ||
const currentCourseId = currentCourseSlot[j].courseId; | ||
const pastFreq = currentRequirementSlotFreq.get(currentCourseId) ?? 0; | ||
currentRequirementSlotFreq.set(currentCourseId, pastFreq + 1); | ||
} | ||
freqList[slotNumber] = currentRequirementSlotFreq; // Update the frequency list | ||
} | ||
res.set(key, freqList); // Update the hashmap with the new frequency list | ||
|
||
}); | ||
}); | ||
|
||
return res; // return the hashmap | ||
} |