Skip to content

Commit

Permalink
Merge pull request #155 from bcgov/Release/v1.6.1
Browse files Browse the repository at this point in the history
fixed district
  • Loading branch information
michaeltangbcgov authored Mar 8, 2024
2 parents 185a03b + dd19adf commit 31e5489
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions backend/src/routes/district-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,25 @@ async function getDistrict(req, res) {
districtSchoolsResponse.data.content = normalizeJsonObject(districtSchoolsResponse.data.content, schoolCategoryCodes, "schoolCategoryCode", null, ["label", "description"]);
districtSchoolsResponse.data.content = normalizeJsonObject(districtSchoolsResponse.data.content, facilityCodes, "faciltyTypeCode", null, ["label", "description"]);
districtSchoolsResponse.data.content = addFundingGroups(districtSchoolsResponse.data.content, fundingGroups)

const today = new Date();
const filteredSchoolsResponse = districtSchoolsResponse.data.content.filter(
(obj) => {
// if openedDate is a valid date is less than today, keep the object
const openedDate = new Date(obj.openedDate);

// If closedDate is a valid date greater than today, keep the object
const closedDate = new Date(obj.closedDate);

// return obj IF closedDate does not exist OR is after than current date
// AND openedDate exists AND is before current date
return (
(!obj.closedDate || closedDate > today) &&
obj.openedDate &&
openedDate < today
);
}
);
const districtJSON = {
districtData: districtDataPublicWithLabels,
districtSchools: filteredSchoolsResponse,
Expand Down

0 comments on commit 31e5489

Please sign in to comment.