Skip to content

Commit

Permalink
fix: resolve empty enrollment history entries (#64)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description
Fixed the issue where the enrollment history endpoint was returning
entries for terms without enrollment data. Now, the endpoint only
returns entries for terms with actual enrollment data, ensuring that
each entry has at least one data point.
<!--- Describe your changes in detail -->

## Related Issue
This pull request addresses issue
[#31](#31).
<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
This change is required to prevent unintentional behavior in consumers
of the enrollment history endpoint. By ensuring that only terms with
enrollment data are returned, we avoid empty data arrays that could
cause issues or unexpected behavior in downstream applications.
## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
Tested on a local deployment by using the pnpm environment. Minor
changes. None affects other code.
## Screenshots (if appropriate):
Before(includes the empty data sections):
<img width="1383" alt="Screenshot 2025-01-06 at 09 54 58"
src="https://github.com/user-attachments/assets/43f04f6d-ac2b-4f57-affd-921d516f50c6"
/>
After(removed the empty data sections):
<img width="1394" alt="Screenshot 2025-01-06 at 09 55 21"
src="https://github.com/user-attachments/assets/6e84ab49-7552-4da5-b130-bc398c7a3862"
/>

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [ ] My code involves a change to the database schema.
- [ ] My code requires a change to the documentation.

---------

Co-authored-by: Eddy Chen <[email protected]>
  • Loading branch information
waterkimchi and ecxyzzy authored Jan 15, 2025
1 parent 4915f90 commit e6a77a1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apps/api/src/services/enrollment-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ export class EnrollmentHistoryService {
section.statusHistory.push(row.status ?? "");
}
}
return transformedSectionRows
.values()
const filteredSections = transformedSectionRows.values().filter((section) => {
return section.dates.length > 0;
});

return filteredSections
.map(({ instructors, meetings, ...rest }) => ({
instructors: Array.from(instructors),
meetings: meetings.map(({ bldg, ...rest }) => ({ bldg: Array.from(bldg), ...rest })),
Expand Down

0 comments on commit e6a77a1

Please sign in to comment.