Skip to content

Commit

Permalink
Fixing formatting and linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloRaigoza committed Sep 21, 2023
1 parent f11b11e commit 06a026f
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions scripts/gen-req-full-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {

import computeGroupedRequirementFulfillmentReports from '../src/requirements/requirement-frontend-computation';

import { RequirementFulfillment, CourseTaken } from '../src/requirement-types';
import { RequirementFulfillment, CourseTaken } from '../src/requirement-types.d';

const idRequirementFrequency = new Map<string, Map<number, number>[]>();

Expand All @@ -20,53 +20,53 @@ async function computeRequirementFullfillmentStatistics() {
// Query a user's semesters
semQuerySnapshot.forEach(async doc => {
// obtain the user's semesters, onboarding data, etc...
let { semesters, _ } = doc.data();
let onboardingData = await onboardingDataCollection.doc(doc.id).get();
let toggleableRequirementChoices = await toggleableRequirementChoicesCollection
const semestersAndPlans = doc.data();
const onboardingData = await onboardingDataCollection.doc(doc.id).get();
const toggleableRequirementChoices = await toggleableRequirementChoicesCollection
.doc(doc.id)
.get();
let overriddenFulfillmentChoices = await overriddenFulfillmentChoicesCollection
const overriddenFulfillmentChoices = await overriddenFulfillmentChoicesCollection
.doc(doc.id)
.get();

// For the given users semesters compute the requirements they fulfill
// and which course it took for them to fulfill them
let res = computeGroupedRequirementFulfillmentReports(
semesters,
const res = computeGroupedRequirementFulfillmentReports(
semestersAndPlans.semester,
onboardingData,
toggleableRequirementChoices,
overriddenFulfillmentChoices
);

res.groupedRequirementFulfillmentReport.forEach(currentGroup => {
let currentGroupReqs: RequirementFulfillment[] = currentGroup.reqs;
const currentGroupReqs: RequirementFulfillment[] = currentGroup.reqs;

// For a given group of requirements, we iterate through all courses
// that were needed to fulfill each slot
currentGroupReqs.forEach(reqFulfillment => {
let key: string = reqFulfillment.requirement.id;
const key: string = reqFulfillment.requirement.id;

let fulfillment: readonly CourseTaken[][] = reqFulfillment.fulfillment
const fulfillment: readonly CourseTaken[][] = reqFulfillment.fulfillment
.safeCourses as readonly CourseTaken[][];

// Obtain the frequency list for this particular group's requirements
let freqList: Map<number, number>[] = idRequirementFrequency.has(key)
const freqList: Map<number, number>[] = idRequirementFrequency.has(key)
? (idRequirementFrequency.get(key) as Map<number, number>[])
: [];

// Iterate over all slots in the requirement group
for (let slotNumber = 0; slotNumber < fulfillment.length; slotNumber++) {
if (freqList.length == slotNumber) {
for (let slotNumber = 0; slotNumber < fulfillment.length; slotNumber += 1) {
if (freqList.length === slotNumber) {
freqList.push(new Map<number, number>());
}
let currentCourseSlot: CourseTaken[] = fulfillment[slotNumber];
let currentRequirementSlotFreq = freqList[slotNumber];
const currentCourseSlot: CourseTaken[] = fulfillment[slotNumber];
const currentRequirementSlotFreq = freqList[slotNumber];

// Iterate over all courses taken to fulfill the req-slot
for (let j = 0; j < currentCourseSlot.length; j++) {
let currentCourseId = currentCourseSlot[j].courseId;
for (let j = 0; j < currentCourseSlot.length; j += 1) {
const currentCourseId = currentCourseSlot[j].courseId;

let pastFreq = currentRequirementSlotFreq.has(currentCourseId)
const pastFreq = currentRequirementSlotFreq.has(currentCourseId)
? (currentRequirementSlotFreq.get(currentCourseId) as number)
: 0;
// Increase frequency each time a course is used to fulfill
Expand All @@ -80,13 +80,13 @@ async function computeRequirementFullfillmentStatistics() {
});

// Serialize the large hashmap into a JSON object
let returnObject = {};
const returnObject = {};
for (const [key, value] of idRequirementFrequency) {
returnObject[key] = value.map(item => ({ ...item }));
}

// Turn the JSON object into a string to output to the console
let returnString = JSON.stringify(returnObject, null, 2);
const returnString = JSON.stringify(returnObject, null, 2);
console.log(returnString);
}

Expand Down

0 comments on commit 06a026f

Please sign in to comment.