Skip to content

Commit

Permalink
remove references to census snapshot code
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroldwong committed May 23, 2024
1 parent 82a8ecb commit 0f3b024
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 52 deletions.
6 changes: 1 addition & 5 deletions app/budget/services/actions/budgetActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ class BudgetActions {
activeTermCodes.forEach(function(termCode) {
DwService.getDwCensusData(subjectCode, null, termCode).then(function(censuses) {
// match courseNumber and TermCode and inject currentEnrollment number
const currentCensusSnapshot = censuses.filter(function(census) {
return census.snapshotCode == "CURRENT";
});

currentCensusSnapshot.forEach(function(courseCensus) {
censuses.forEach(function(courseCensus) {
sectionGroupCosts.forEach(function(sectionGroupCost) {
const censusSequencePattern = isNaN(Number(courseCensus.sequenceNumber)) ? courseCensus.sequenceNumber.charAt(0) : courseCensus.sequenceNumber;
const sectionGroupCostKey = `${sectionGroupCost.subjectCode}-${sectionGroupCost.courseNumber}-${sectionGroupCost.termCode}-${sectionGroupCost.sequencePattern}`;
Expand Down
2 changes: 1 addition & 1 deletion app/course/directives/censusChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let censusChart = function ($rootScope, $timeout) {
// Gets the "CURRENT" snapshot of the given property (e.g. currentEnrolledCount, maxEnrollmentCount)
var getCurrentCensusForProperty = function (property) {
var sequenceFilteredCensus = scope.census.filter(function(courseCensus) {
return courseCensus.sequenceNumber.includes(scope.sequencePattern) && courseCensus.snapshotCode === "CURRENT";
return courseCensus.sequenceNumber.includes(scope.sequencePattern);
});

var censusByTermCode = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,26 @@ class ScheduleSummaryReportActionCreators {
});
},
_getEnrollmentData: function(year, termCode) {
var SNAPSHOT_CODE = "CURRENT";
var termCode = termService.termToTermCode(termCode, year);
var subjectCodes = this._getScheduleSubjectCodes();

subjectCodes.forEach(function(subjectCode) {
dwService.getDwCensusData(subjectCode, null, termCode).then(function(censusSections) {
censusSections.forEach(function(censusSection) {
if (censusSection.snapshotCode == SNAPSHOT_CODE) {
var censusSectionGroupKey = censusSection.subjectCode + censusSection.courseNumber + sequenceNumberToPattern(censusSection.sequenceNumber);
var censusSectionGroupKey = censusSection.subjectCode + censusSection.courseNumber + sequenceNumberToPattern(censusSection.sequenceNumber);

scheduleSummaryReportStateService._state.sectionGroups.ids.forEach(function(sectionGroupId) {
var sectionGroup = scheduleSummaryReportStateService._state.sectionGroups.list[sectionGroupId];
var sectionGroupUniqueKey = sectionGroup.subjectCode + sectionGroup.courseNumber + sectionGroup.sequencePattern;
scheduleSummaryReportStateService._state.sectionGroups.ids.forEach(function(sectionGroupId) {
var sectionGroup = scheduleSummaryReportStateService._state.sectionGroups.list[sectionGroupId];
var sectionGroupUniqueKey = sectionGroup.subjectCode + sectionGroup.courseNumber + sectionGroup.sequencePattern;

if (sectionGroupUniqueKey == censusSectionGroupKey) {
sectionGroup.sections.forEach(function(section) {
if (section.sequenceNumber == censusSection.sequenceNumber) {
section.enrollment = censusSection.currentEnrolledCount;
}
});
}
});
}
if (sectionGroupUniqueKey == censusSectionGroupKey) {
sectionGroup.sections.forEach(function(section) {
if (section.sequenceNumber == censusSection.sequenceNumber) {
section.enrollment = censusSection.currentEnrolledCount;
}
});
}
});
});
}, function () {
$rootScope.$emit('toast', { message: "Could not retrieve enrollment data.", type: "ERROR" });
Expand Down
54 changes: 23 additions & 31 deletions app/workloadSummaryReport/services/workloadSummaryActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,9 @@ class WorkloadSummaryActions {
courses.ids.forEach(function (courseId) {
var course = courses.list[courseId];
course.census = [];
var SNAPSHOT_CODE = "CURRENT";

DwService.getDwCensusData(course.subjectCode, course.courseNumber).then(function (courseCensus) {
courseCensus.forEach(function (census) {
if (census.snapshotCode === SNAPSHOT_CODE) {
course.census.push(census);
}
});
course.census = courseCensus;
});
});

Expand Down Expand Up @@ -1050,7 +1045,6 @@ class WorkloadSummaryActions {
}
});

var SNAPSHOT_CODE = "CURRENT";
var termCodes = this._getScheduleTermCodes(isPreviousYear);
var subjectCodes = this._getScheduleSubjectCodes();
var openCalls = WorkloadSummaryReducers._state.calculations.dwCallsOpened;
Expand All @@ -1062,31 +1056,29 @@ class WorkloadSummaryActions {

DwService.getDwCensusData(subjectCode, null, termCode).then(function(censusSections) {
censusSections.forEach(function(censusSection) {
if (censusSection.snapshotCode == SNAPSHOT_CODE) {
var censusSectionGroupKey = censusSection.subjectCode + censusSection.courseNumber + sequenceNumberToPattern(censusSection.sequenceNumber) + TermService.termCodeToTerm(censusSection.termCode);

WorkloadSummaryReducers._state.sectionGroups.ids.forEach(function(sectionGroupId) {
var sectionGroup = WorkloadSummaryReducers._state.sectionGroups.list[sectionGroupId];
var course = WorkloadSummaryReducers._state.courses.list[sectionGroup.courseId];
var sectionGroupUniqueKey = course.subjectCode + course.courseNumber + course.sequencePattern + TermService.termCodeToTerm(sectionGroup.termCode);

sectionGroup.maxEnrollment = sectionGroup.maxEnrollment || 0;
sectionGroup.actualEnrollment = sectionGroup.actualEnrollment || 0;
sectionGroup.previousEnrollment = sectionGroup.previousEnrollment || 0;

if (sectionGroupUniqueKey == censusSectionGroupKey) {
if (isPreviousYear) {
sectionGroup.previousEnrollment += censusSection.currentEnrolledCount;
} else {
sectionGroup.actualEnrollment += censusSection.currentEnrolledCount;
sectionGroup.maxEnrollment = 0;
_self._getSectionsForSectionGroup(sectionGroup).forEach(function(section) {
sectionGroup.maxEnrollment += section.seats;
});
}
var censusSectionGroupKey = censusSection.subjectCode + censusSection.courseNumber + sequenceNumberToPattern(censusSection.sequenceNumber) + TermService.termCodeToTerm(censusSection.termCode);

WorkloadSummaryReducers._state.sectionGroups.ids.forEach(function(sectionGroupId) {
var sectionGroup = WorkloadSummaryReducers._state.sectionGroups.list[sectionGroupId];
var course = WorkloadSummaryReducers._state.courses.list[sectionGroup.courseId];
var sectionGroupUniqueKey = course.subjectCode + course.courseNumber + course.sequencePattern + TermService.termCodeToTerm(sectionGroup.termCode);

sectionGroup.maxEnrollment = sectionGroup.maxEnrollment || 0;
sectionGroup.actualEnrollment = sectionGroup.actualEnrollment || 0;
sectionGroup.previousEnrollment = sectionGroup.previousEnrollment || 0;

if (sectionGroupUniqueKey == censusSectionGroupKey) {
if (isPreviousYear) {
sectionGroup.previousEnrollment += censusSection.currentEnrolledCount;
} else {
sectionGroup.actualEnrollment += censusSection.currentEnrolledCount;
sectionGroup.maxEnrollment = 0;
_self._getSectionsForSectionGroup(sectionGroup).forEach(function(section) {
sectionGroup.maxEnrollment += section.seats;
});
}
});
}
}
});
});

completedCalls += 1;
Expand Down

0 comments on commit 0f3b024

Please sign in to comment.