Skip to content

Commit

Permalink
Merge pull request #143 from bcgov/release/v1.4.1
Browse files Browse the repository at this point in the history
Fix schools with status of closing and opening appearing incorrectly …
  • Loading branch information
suzalflueck authored Jan 11, 2024
2 parents 5695662 + 34e485b commit b1a4f58
Show file tree
Hide file tree
Showing 2 changed files with 237 additions and 120 deletions.
15 changes: 10 additions & 5 deletions backend/src/routes/authority-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,19 @@ async function getAuthority(req, res) {
const today = new Date();
const filteredSchoolsResponse =
authoritySchoolsResponse.data.content.filter((obj) => {
// If closedDate is null, keep the object
if (obj.closedDate === null) {
return true;
}
// 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 closedDate > today;

// 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 authorityJSON = {
authorityData: authorityDataResponse.data,
Expand Down
Loading

0 comments on commit b1a4f58

Please sign in to comment.