Skip to content

Commit

Permalink
add seat reservation types to enrollment datapuller
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmwang committed Feb 10, 2025
1 parent f40b254 commit 9ad0369
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apps/datapuller/src/lib/enrollment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ const formatEnrollmentSingular = (input: ClassSection, time: Date) => {
input.enrollmentStatus?.instructorAddConsentRequired,
instructorDropConsentRequired:
input.enrollmentStatus?.instructorDropConsentRequired,
seatReservations: input.enrollmentStatus?.seatReservations?.map(
seatReservationCounts: input.enrollmentStatus?.seatReservations?.map(
(reservation) => ({
number: reservation.number,
maxEnroll: reservation.maxEnroll,
enrolledCount: reservation.enrolledCount,
})
),
},
seatReservations: input.enrollmentStatus?.seatReservations?.map(
seatReservationTypes: input.enrollmentStatus?.seatReservations?.map(
(reservation) => ({
number: reservation.number,
requirementGroup: reservation.requirementGroup?.description,
Expand Down
16 changes: 10 additions & 6 deletions apps/datapuller/src/pullers/enrollment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ const enrollmentSingularsEqual = (
}

const aSeatReservationsEmpty =
a.seatReservations == undefined || a.seatReservations.length == 0;
a.seatReservationCounts == undefined || a.seatReservationCounts.length == 0;
const bSeatReservationsEmpty =
b.seatReservations == undefined || b.seatReservations.length == 0;
b.seatReservationCounts == undefined || b.seatReservationCounts.length == 0;
if (aSeatReservationsEmpty != bSeatReservationsEmpty) {
return false;
}

if (a.seatReservations && b.seatReservations) {
if (a.seatReservations.length !== b.seatReservations.length) return false;
for (const aSeats of a.seatReservations) {
const bSeats = b.seatReservations.find(
if (a.seatReservationCounts && b.seatReservationCounts) {
if (a.seatReservationCounts.length !== b.seatReservationCounts.length)
return false;
for (const aSeats of a.seatReservationCounts) {
const bSeats = b.seatReservationCounts.find(
(bSeats) => bSeats.number === aSeats.number
);
if (
Expand Down Expand Up @@ -131,6 +132,9 @@ const updateEnrollmentHistories = async ({
sectionId: enrollmentSingular.sectionId,
},
{
$setOnInsert: {
seatReservationTypes: enrollmentSingular.seatReservationTypes,
},
$push: {
history: enrollmentSingular.data,
},
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/models/enrollment-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface IEnrollmentHistoryItem {

// maps number to requirementGroup.
// this assumes that these fields are constant over time.
seatReservations?: {
seatReservationTypes?: {
number: number;
requirementGroup?: string;
fromDate: string;
Expand All @@ -24,7 +24,7 @@ export interface IEnrollmentHistoryItem {
openReserved?: number;
instructorAddConsentRequired?: boolean;
instructorDropConsentRequired?: boolean;
seatReservations?: {
seatReservationCounts?: {
number: number; // maps to seatReservations.number to get requirementGroup
maxEnroll: number;
enrolledCount?: number;
Expand Down Expand Up @@ -59,7 +59,7 @@ const enrollmentHistorySchema = new Schema<IEnrollmentHistoryItem>({
openReserved: { type: Number },
instructorAddConsentRequired: { type: Boolean },
instructorDropConsentRequired: { type: Boolean },
seatReservations: [
seatReservationCounts: [
{
_id: false,
number: { type: Number },
Expand All @@ -69,7 +69,7 @@ const enrollmentHistorySchema = new Schema<IEnrollmentHistoryItem>({
],
},
],
seatReservations: [
seatReservationTypes: [
{
_id: false,
number: { type: Number },
Expand Down

0 comments on commit 9ad0369

Please sign in to comment.