Skip to content

Commit

Permalink
Merge branch 'release/v1.8.0' of https://github.com/bcgov/EDUC-SDCI i…
Browse files Browse the repository at this point in the history
…nto sdci-114
  • Loading branch information
suzalflueck committed Aug 1, 2024
2 parents 49a10f2 + 6ce9f13 commit a75c4c6
Show file tree
Hide file tree
Showing 28 changed files with 940 additions and 863 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-n-deploy-backend-to-ocp-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,6 @@ jobs:
oc rollout status dc/${{ env.IMAGE_NAME }}
- name: ZAP Scan
uses: zaproxy/action-full-scan@v0.3.0
uses: zaproxy/action-full-scan@v0.10.0
with:
target: "https://${{ env.HOST_ROUTE }}"
2 changes: 1 addition & 1 deletion .github/workflows/deploy-to.openshift-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ jobs:
oc rollout status dc/${{ env.IMAGE_NAME }}
- name: ZAP Scan
uses: zaproxy/action-full-scan@v0.3.0
uses: zaproxy/action-full-scan@v0.10.0
with:
target: "https://${{ env.HOST_ROUTE }}"
2 changes: 1 addition & 1 deletion .github/workflows/deploy-to.openshift-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ jobs:
oc rollout status dc/${{ env.IMAGE_NAME }}
- name: ZAP Scan
uses: zaproxy/action-full-scan@v0.3.0
uses: zaproxy/action-full-scan@v0.10.0
with:
target: "https://${{ env.HOST_ROUTE }}"
10 changes: 5 additions & 5 deletions backend/src/components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function removeFieldsByCriteria(inputData, criteria) {
}
function appendMailingAddressDetailsAndRemoveAddresses(data) {
if (data && data.addresses && data.addresses.length > 0) {
const physicalAddress = data.addresses.find(
const physicalAddress = data.addresses?.find(
(address) => address.addressTypeCode === "PHYSICAL"
);
if (physicalAddress) {
Expand All @@ -101,7 +101,7 @@ function appendMailingAddressDetailsAndRemoveAddresses(data) {

// Remove the "addresses" property
}
const courierAddress = data.addresses.find(
const courierAddress = data.addresses?.find(
(address) => address.addressTypeCode === "MAILING"
);
if (courierAddress) {
Expand Down Expand Up @@ -132,7 +132,7 @@ function appendMailingAddressDetailsAndRemoveAddresses(data) {
function addDistrictLabels(jsonData, districtList) {
if (jsonData.content && Array.isArray(jsonData.content)) {
jsonData.content.forEach((dataItem) => {
const district = districtList.find(
const district = districtList?.find(
(item) => item.districtId === dataItem.districtId
);
if (district) {
Expand Down Expand Up @@ -229,7 +229,7 @@ function normalizeJsonObject(
includeFields
) {
return sourceArray.map((item) => {
const matchingItem = referenceArray.find(
const matchingItem = referenceArray?.find(
(info) =>
info[matchKey] === item[matchKey] && (!condition || condition(info))
);
Expand Down Expand Up @@ -402,7 +402,7 @@ function createSchoolCache(schoolData, schoolGrades) {
});

// Extract and format principal contact information if it exists
const principalContact = school.contacts.find(
const principalContact = school.contacts?.find(
(contact) => contact.schoolContactTypeCode === "PRINCIPAL"
);
if (principalContact) {
Expand Down
73 changes: 36 additions & 37 deletions backend/src/routes/district-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function addContactTypeLabels(districtDataResponse, nonPublicContactTypeCodes) {
Array.isArray(updatedDistrictData.contacts)
) {
updatedDistrictData.contacts.forEach((contact) => {
const matchingType = nonPublicContactTypeCodes.find(
const matchingType = nonPublicContactTypeCodes?.find(
(codeObj) =>
codeObj.districtContactTypeCode === contact.districtContactTypeCode
);
Expand Down Expand Up @@ -93,7 +93,7 @@ async function getDistrictCodes(req) {
return districtCodeList;
} catch (e) {
log.error(
"getDistrictList Error",
"getDistrictCodesList Error",
e.response ? e.response.status : e.message
);
}
Expand Down Expand Up @@ -250,7 +250,6 @@ async function getAllDistrictContacts(req, res) {

async function getAllDistrictMailing(req, res) {
const districtList = await listCache.get("districtlist");
const contactTypeCodes = await listCache.get("codesList");

const propertyOrder = [
{ property: "districtId_districtNumber", label: "District Number" },
Expand Down Expand Up @@ -323,13 +322,11 @@ async function getAllDistrictMailing(req, res) {
const contentByDistrict = sortJSONByDistrictNumber(content);

res.json(contentByDistrict);
//res.json(districtContactsReorderedAndRelabeled );
} catch (e) {
log.error("getData Error", e.response ? e.response.status : e.message);
}
}

//api/v1/institute/district/12342525
async function getDistrict(req, res) {
const { id } = req.params;

Expand Down Expand Up @@ -424,8 +421,9 @@ async function getDistrict(req, res) {
const facilityCodes = await listCache.get("facilityCodes");
const fundingGroups = await listCache.get("fundingGroups");
const districtContactCodeTypes = await listCache.get("codesList");
const nonPublicContactTypeCodes =
getNonPublicContactTypeCodes(contactTypeCodes);
const nonPublicContactTypeCodes = await getNonPublicContactTypeCodes(
contactTypeCodes
);

const districtDataPublic = removeContacts(
districtDataResponse.data,
Expand All @@ -435,36 +433,37 @@ async function getDistrict(req, res) {
districtDataPublic,
contactTypeCodes
);
districtDataPublicWithLabels.contacts = filterByPubliclyAvailableCodes(
districtDataPublicWithLabels.contacts,
"districtContactTypeCode",
getArrayofPubliclyAvailableCodes(
districtContactCodeTypes.codesList.districtContactTypeCodes,
"districtContactTypeCode"
)
);
districtDataPublicWithLabels.contacts = filterByExpiryDate(
districtDataPublicWithLabels.contacts
);

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
);
if (!!districtContactCodeTypes) {
districtDataPublicWithLabels.contacts = filterByPubliclyAvailableCodes(
districtDataPublicWithLabels.contacts,
"districtContactTypeCode",
getArrayofPubliclyAvailableCodes(
districtContactCodeTypes.codesList.districtContactTypeCodes,
"districtContactTypeCode"
)
);
districtDataPublicWithLabels.contacts = filterByExpiryDate(
districtDataPublicWithLabels.contacts
);
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(
Expand Down
Loading

0 comments on commit a75c4c6

Please sign in to comment.