From 4f4baa43c966a3cf04432d2480b5aa95fabe46c7 Mon Sep 17 00:00:00 2001 From: Tang Date: Fri, 5 Jan 2024 09:10:41 -0800 Subject: [PATCH 01/13] added the fiters for contact dates --- frontend/src/views/ContactsView.vue | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/frontend/src/views/ContactsView.vue b/frontend/src/views/ContactsView.vue index 6caea00..833d340 100644 --- a/frontend/src/views/ContactsView.vue +++ b/frontend/src/views/ContactsView.vue @@ -63,6 +63,27 @@ const searchContact = async () => { } ] if (selectedContactType.value) { + params[0].searchCriteriaList.push({ + key: 'expiryDate', + operation: 'eq', + value: null, + valueType: 'STRING', + condition: 'OR' + }) + params[0].searchCriteriaList.push({ + key: 'expiryDate', + operation: 'gte', + value: currentDate, + valueType: 'DATE_TIME', + condition: 'OR' + }) + params[0].searchCriteriaList.push({ + key: 'effectiveDate', + operation: 'lte', + value: currentDate, + valueType: 'DATE_TIME', + condition: 'AND' + }) params[0].searchCriteriaList.push({ key: 'districtContactTypeCode', operation: 'eq', @@ -70,11 +91,26 @@ const searchContact = async () => { valueType: 'STRING', condition: 'AND' }) + } else { params[0].searchCriteriaList.push({ key: 'expiryDate', operation: 'eq', value: null, valueType: 'STRING', + condition: 'OR' + }) + params[0].searchCriteriaList.push({ + key: 'expiryDate', + operation: 'gte', + value: currentDate, + valueType: 'DATE_TIME', + condition: 'OR' + }) + params[0].searchCriteriaList.push({ + key: 'effectiveDate', + operation: 'lte', + value: currentDate, + valueType: 'DATE_TIME', condition: 'AND' }) } From 5aba82fe0e8bd3cdcdaf8139d645ce68c96c59a1 Mon Sep 17 00:00:00 2001 From: Tang Date: Wed, 14 Feb 2024 11:22:24 -0800 Subject: [PATCH 02/13] SDCI-94 changes --- frontend/src/views/ContactsView.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/ContactsView.vue b/frontend/src/views/ContactsView.vue index 833d340..5f02657 100644 --- a/frontend/src/views/ContactsView.vue +++ b/frontend/src/views/ContactsView.vue @@ -53,6 +53,11 @@ const transformContactForDownload = (inputData: any) => { email: item.email })) } +const filterOutYukon = (inputData: any) => { + return inputData.filter( + (contact) => contact.districtId !== '54396317-b444-063d-779e-e4d42ff7634f' + ) +} const searchContact = async () => { // Filter contacts based on selected filters let currentDate = new Date().toISOString().substring(0, 19) @@ -123,7 +128,8 @@ const searchContact = async () => { } try { const searchResults = await InstituteService.searchContactByType(req) - filteredContacts.value = transformContactForDownload(searchResults.data.content) + const yukonFilteredContacts = filterOutYukon(searchResults.data.content) + filteredContacts.value = transformContactForDownload(yukonFilteredContacts) results.value = searchResults.data.totalElements // Update current page and total pages totalPages.value = searchResults.data.totalPages From c73aef4df01f09f35567676b917a5c085d034887 Mon Sep 17 00:00:00 2001 From: Tang Date: Wed, 14 Feb 2024 11:35:47 -0800 Subject: [PATCH 03/13] fixes for SDCI-94 --- frontend/src/views/ContactsView.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/ContactsView.vue b/frontend/src/views/ContactsView.vue index 5f02657..ca861fe 100644 --- a/frontend/src/views/ContactsView.vue +++ b/frontend/src/views/ContactsView.vue @@ -55,7 +55,8 @@ const transformContactForDownload = (inputData: any) => { } const filterOutYukon = (inputData: any) => { return inputData.filter( - (contact) => contact.districtId !== '54396317-b444-063d-779e-e4d42ff7634f' + (contact: { districtId: string }) => + contact.districtId !== '54396317-b444-063d-779e-e4d42ff7634f' ) } const searchContact = async () => { From 1d3b87868294b107eba04775334716d0d46956c6 Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Fri, 23 Feb 2024 12:17:30 -0800 Subject: [PATCH 04/13] sdci-97v2 --- backend/src/routes/school-router.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/routes/school-router.js b/backend/src/routes/school-router.js index 4c46894..07c078a 100644 --- a/backend/src/routes/school-router.js +++ b/backend/src/routes/school-router.js @@ -276,7 +276,10 @@ async function getAllSchools(req, res) { { property: "mailing_city", label: "City" }, { property: "mailing_provinceCode", label: "Province" }, { property: "mailing_postal", label: "Postal Code" }, - // { property: "principalTitle", label: "Principal Title" }, + { property: "physical_addressLine1", label: "Physical Address" }, + { property: "physical_city", label: "Physical City" }, + { property: "physical_provinceCode", label: "Physical Province" }, + { property: "physical_postal", label: "Physical Postal Code" }, { property: "firstName", label: "Principal First Name" }, { property: "lastName", label: "Principal Last Name" }, { property: "facilityTypeCode", label: "Type" }, From 2d912647eac7fe3a34952248f2b1ae26aee4a69f Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Tue, 5 Mar 2024 06:38:05 -0800 Subject: [PATCH 05/13] added endpoints for schools --- backend/src/config/index.js | 1 + backend/src/routes/institute-router.js | 30 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/backend/src/config/index.js b/backend/src/config/index.js index c9737a4..477991a 100644 --- a/backend/src/config/index.js +++ b/backend/src/config/index.js @@ -31,6 +31,7 @@ nconf.defaults({ maxAge: +process.env.SESSION_MAX_AGE }, instituteAPIURL: process.env.INSTITUTE_API_URL, + schoolsAPIURL: process.env.SCHOOLS_API_URL, instituteAPITokenExpiry: process.env.INSTITUTE_API_EXPIRY, clearFilesKey: process.env.CLEAR_FILES_KEY }, diff --git a/backend/src/routes/institute-router.js b/backend/src/routes/institute-router.js index 1e766d8..c2870b6 100644 --- a/backend/src/routes/institute-router.js +++ b/backend/src/routes/institute-router.js @@ -38,7 +38,37 @@ router.get("/district/list", checkToken, getDistrictList); router.get("/district/contact/*", checkToken, getDistrictContactsAPI); router.get("/create-cache", checkToken, createCache); router.get("/category-codes", checkToken, getCategoryCodes); +router.get("/schools/getFundingGroups", checkToken, getFundingGroups); + router.get("/*", checkToken, getInstituteAPI); + +async function getFundingGroups(req, res) { + if (await !listCache.has("fundingGroups")) { + //const codes = []; + + try { + const fundingGroupsResponse = await axios.get( + `${config.get( + "server:schoolsAPIURL" + )}/schools/fundingGroups`, + { + headers: { Authorization: `Bearer ${req.accessToken}` }, + } + ); + + res.json(fundingGroupsResponse); + listCache.set("fundingGroups", fundingGroupsResponse); + } catch (error) { + const statusCode = error.response ? error.response.status : 500; + log.error("getContactCodeList Error", statusCode, error.message); + res.status(statusCode).send(error.message); + } + listCache.set("codesList", codes); + } else { + const cachedCodeList = await listCache.get("codesList"); + res.json(cachedCodeList); + } +} async function createCache(req, res) { if (await !listCache.has("districtlist")) { const url = `${config.get("server:instituteAPIURL")}/institute/district`; // Update the URL according to your API endpoint From 228e5abc5f51711e7a930a045223a12788375139 Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Tue, 5 Mar 2024 16:13:28 -0800 Subject: [PATCH 06/13] updates --- backend/src/components/utils.js | 26 +++++++++++++++++++++++++- backend/src/routes/institute-router.js | 23 +++++++++-------------- backend/src/routes/school-router.js | 9 +++++++-- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/backend/src/components/utils.js b/backend/src/components/utils.js index aaf0e63..dd3dd79 100644 --- a/backend/src/components/utils.js +++ b/backend/src/components/utils.js @@ -274,6 +274,30 @@ function addDistrictLabels(jsonData, districtList) { return nonPubliclyAvailableCodes; } + function addFundingGroups(jsonData, fundingGroups) { + + // Iterate over each school in jsonData + jsonData.forEach(school => { + // Find the corresponding funding group by mincode + const matchingFundingGroup = fundingGroups.find(fundingGroup => fundingGroup.mincode === school.mincode); + + // Add fundingGroupCode and fundingGroupSubCode to the school + if (matchingFundingGroup) { + Object.assign(school, { + fundingGroupCode: matchingFundingGroup.fundingGroupCode, + fundingGroupSubCode: matchingFundingGroup.fundingGroupSubCode, + }); + } else { + // If mincode is not found in fundingGroups, add null values + Object.assign(school, { + fundingGroupCode: null, + fundingGroupSubCode: null, + }); + } + }); + + return jsonData; +} function getArrayofPubliclyAvailableCodes(codes, field) { if (!Array.isArray(codes)) { throw new Error('Invalid input. Expecting an array of objects.'); @@ -377,4 +401,4 @@ function addDistrictLabels(jsonData, districtList) { return school; }); } - module.exports = {filterByOpenedAndClosedDate, filterByPubliclyAvailableCodes, getArrayofPubliclyAvailableCodes, filterByExpiryDate, filterRemoveByField,filterIncludeByField, sortByProperty,getArrayofNonPubliclyAvailableCodes,filterByField,appendMailingAddressDetailsAndRemoveAddresses,sortJSONBySchoolCode,sortJSONByDistrictNumber,normalizeJsonObject, removeFieldsByCriteria, createList, isSafeFilePath,isAllowedSchoolCategory, addDistrictLabels, districtNumberSort, createSchoolCache, formatGrades, rearrangeAndRelabelObjectProperties}; \ No newline at end of file + module.exports = {addFundingGroups, filterByOpenedAndClosedDate, filterByPubliclyAvailableCodes, getArrayofPubliclyAvailableCodes, filterByExpiryDate, filterRemoveByField,filterIncludeByField, sortByProperty,getArrayofNonPubliclyAvailableCodes,filterByField,appendMailingAddressDetailsAndRemoveAddresses,sortJSONBySchoolCode,sortJSONByDistrictNumber,normalizeJsonObject, removeFieldsByCriteria, createList, isSafeFilePath,isAllowedSchoolCategory, addDistrictLabels, districtNumberSort, createSchoolCache, formatGrades, rearrangeAndRelabelObjectProperties}; \ No newline at end of file diff --git a/backend/src/routes/institute-router.js b/backend/src/routes/institute-router.js index c2870b6..654bbad 100644 --- a/backend/src/routes/institute-router.js +++ b/backend/src/routes/institute-router.js @@ -38,11 +38,10 @@ router.get("/district/list", checkToken, getDistrictList); router.get("/district/contact/*", checkToken, getDistrictContactsAPI); router.get("/create-cache", checkToken, createCache); router.get("/category-codes", checkToken, getCategoryCodes); -router.get("/schools/getFundingGroups", checkToken, getFundingGroups); router.get("/*", checkToken, getInstituteAPI); -async function getFundingGroups(req, res) { +async function createCache(req, res) { if (await !listCache.has("fundingGroups")) { //const codes = []; @@ -55,21 +54,17 @@ async function getFundingGroups(req, res) { headers: { Authorization: `Bearer ${req.accessToken}` }, } ); - - res.json(fundingGroupsResponse); - listCache.set("fundingGroups", fundingGroupsResponse); + listCache.set("fundingGroups", fundingGroupsResponse.data); + res.json(fundingGroupsResponse.data); } catch (error) { const statusCode = error.response ? error.response.status : 500; - log.error("getContactCodeList Error", statusCode, error.message); + log.error("getFunding Groups Error", statusCode, error.message); res.status(statusCode).send(error.message); } - listCache.set("codesList", codes); } else { - const cachedCodeList = await listCache.get("codesList"); - res.json(cachedCodeList); + const cachedFundingGroupList = await listCache.get("fundingGroups"); + res.json(cachedFundingGroupList); } -} -async function createCache(req, res) { if (await !listCache.has("districtlist")) { const url = `${config.get("server:instituteAPIURL")}/institute/district`; // Update the URL according to your API endpoint axios @@ -273,7 +268,6 @@ async function createCache(req, res) { log.error("getCodesList Error", statusCode, error.message); res.status(statusCode).send(error.message); } - listCache.set("codesList", codes); } res.status(200).json({ success: true }); @@ -317,15 +311,16 @@ async function getContactTypeCodes(req, res) { districtContactTypeCodes: removeFieldsByCriteria(districtContactTypeCodesResponse.data,[{ fieldToRemove: "publiclyAvailable", value: false }]), schoolContactTypeCodes: removeFieldsByCriteria(schoolContactTypeCodesResponse.data,[{ fieldToRemove: "publiclyAvailable", value: false }]), }; - res.json(codes); listCache.set("codesList", { codesList: codes }); + console.log(codes) + res.json(codes); } catch (error) { const statusCode = error.response ? error.response.status : 500; log.error("getContactCodeList Error", statusCode, error.message); res.status(statusCode).send(error.message); } - listCache.set("codesList", codes); } else { + console.log("set CODELIST") const cachedCodeList = await listCache.get("codesList"); res.json(cachedCodeList); } diff --git a/backend/src/routes/school-router.js b/backend/src/routes/school-router.js index 4c46894..5318e93 100644 --- a/backend/src/routes/school-router.js +++ b/backend/src/routes/school-router.js @@ -17,6 +17,7 @@ const { sortJSONBySchoolCode, rearrangeAndRelabelObjectProperties, filterByPubliclyAvailableCodes, + addFundingGroups } = require("../components/utils"); const { checkToken } = require("../components/auth"); const { schoolCache, listCache, codeCache } = require("../components/cache"); @@ -28,13 +29,14 @@ router.get("/:schoolId", checkToken, getSchool); async function getSchool(req, res) { const { schoolId } = req.params; + console.log(await listCache.get("fundingGroups")) const contactTypeCodes = await listCache.get("codesList"); + const fundingGroups = await listCache.get("fundingGroups"); const url = `${config.get("server:instituteAPIURL")}/institute/school/` + schoolId; axios .get(url, { headers: { Authorization: `Bearer ${req.accessToken}` } }) .then((response) => { - //const openSchoolList = createList(response.data, openSchoolListOptions); const schoolGrades = [ { schoolGradeCode: "KINDHALF", @@ -175,6 +177,7 @@ async function getSchool(req, res) { (info) => info.publiclyAvailable === true, includedFields ); + schoolData.contacts = filterByPubliclyAvailableCodes( schoolData.contacts, @@ -187,7 +190,9 @@ async function getSchool(req, res) { schoolData.contacts = filterByExpiryDate(schoolData.contacts); const formattedGrades = formatGrades(schoolData.grades, schoolGrades); const schoolWithFormattedGrades = { ...schoolData, ...formattedGrades }; - res.json(schoolWithFormattedGrades); + const schoolsWithFundingGroups = addFundingGroups(schoolWithFormattedGrades, fundingGroups) + res.json(schoolsWithFundingGroups); + }) .catch((e) => { log.error("getSchools Error", e.response ? e.response.status : e.message); From e365659f34dbf557ecb457abc14fe874006b134e Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Thu, 7 Mar 2024 10:29:13 -0800 Subject: [PATCH 07/13] backend changes for authority --- backend/src/components/utils.js | 18 +++++++++++------- backend/src/routes/district-router.js | 5 +++-- backend/src/routes/institute-router.js | 2 +- backend/src/routes/school-router.js | 16 +++++++++++----- frontend/src/views/DistrictView.vue | 4 +++- frontend/src/views/SchoolView.vue | 8 ++++++++ 6 files changed, 37 insertions(+), 16 deletions(-) diff --git a/backend/src/components/utils.js b/backend/src/components/utils.js index dd3dd79..b583a90 100644 --- a/backend/src/components/utils.js +++ b/backend/src/components/utils.js @@ -274,12 +274,15 @@ function addDistrictLabels(jsonData, districtList) { return nonPubliclyAvailableCodes; } - function addFundingGroups(jsonData, fundingGroups) { - - // Iterate over each school in jsonData - jsonData.forEach(school => { + function addFundingGroups(schools, fundingGroups) { + // Process each school in the array + + const schoolsWithFunding = schools.map(school => { // Find the corresponding funding group by mincode - const matchingFundingGroup = fundingGroups.find(fundingGroup => fundingGroup.mincode === school.mincode); + const matchingFundingGroup = fundingGroups.find(fundingGroup => + fundingGroup.mincode === school.mincode + ); + // Add fundingGroupCode and fundingGroupSubCode to the school if (matchingFundingGroup) { @@ -294,9 +297,10 @@ function addDistrictLabels(jsonData, districtList) { fundingGroupSubCode: null, }); } - }); - return jsonData; + return school; + }); + return schoolsWithFunding; } function getArrayofPubliclyAvailableCodes(codes, field) { if (!Array.isArray(codes)) { diff --git a/backend/src/routes/district-router.js b/backend/src/routes/district-router.js index 498abe8..74c4745 100644 --- a/backend/src/routes/district-router.js +++ b/backend/src/routes/district-router.js @@ -8,7 +8,7 @@ const fs = require("fs"); const path = require("path"); const { checkToken } = require("../components/auth"); const { listCache} = require("../components/cache"); -const {getArrayofPubliclyAvailableCodes,filterRemoveByField, filterByExpiryDate, getArrayofNonPubliclyAvailableCodes, filterByField,appendMailingAddressDetailsAndRemoveAddresses, rearrangeAndRelabelObjectProperties, addDistrictLabels, normalizeJsonObject, sortJSONByDistrictNumber, removeFieldsByCriteria, filterByPubliclyAvailableCodes} = require("../components/utils.js") +const {addFundingGroups, getArrayofPubliclyAvailableCodes,filterRemoveByField, filterByExpiryDate, getArrayofNonPubliclyAvailableCodes, filterByField,appendMailingAddressDetailsAndRemoveAddresses, rearrangeAndRelabelObjectProperties, addDistrictLabels, normalizeJsonObject, sortJSONByDistrictNumber, removeFieldsByCriteria, filterByPubliclyAvailableCodes} = require("../components/utils.js") //Batch Routes router.get("/all-contacts", checkToken, getAllDistrictContacts); @@ -323,6 +323,7 @@ async function getDistrict(req, res) { const contactTypeCodes = await getDistrictCodes(req); const schoolCategoryCodes = await listCache.get("categoryCodes") const facilityCodes = await listCache.get("facilityCodes") + const fundingGroups = await listCache.get("fundingGroups") const districtContactCodeTypes = await listCache.get("codesList") const nonPublicContactTypeCodes = getNonPublicContactTypeCodes(contactTypeCodes); @@ -341,7 +342,7 @@ 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 districtJSON = { districtData: districtDataPublicWithLabels, districtSchools: districtSchoolsResponse.data.content, diff --git a/backend/src/routes/institute-router.js b/backend/src/routes/institute-router.js index 654bbad..0c381fb 100644 --- a/backend/src/routes/institute-router.js +++ b/backend/src/routes/institute-router.js @@ -54,6 +54,7 @@ async function createCache(req, res) { headers: { Authorization: `Bearer ${req.accessToken}` }, } ); + console.log("SET") listCache.set("fundingGroups", fundingGroupsResponse.data); res.json(fundingGroupsResponse.data); } catch (error) { @@ -312,7 +313,6 @@ async function getContactTypeCodes(req, res) { schoolContactTypeCodes: removeFieldsByCriteria(schoolContactTypeCodesResponse.data,[{ fieldToRemove: "publiclyAvailable", value: false }]), }; listCache.set("codesList", { codesList: codes }); - console.log(codes) res.json(codes); } catch (error) { const statusCode = error.response ? error.response.status : 500; diff --git a/backend/src/routes/school-router.js b/backend/src/routes/school-router.js index 5318e93..7f577b5 100644 --- a/backend/src/routes/school-router.js +++ b/backend/src/routes/school-router.js @@ -29,9 +29,9 @@ router.get("/:schoolId", checkToken, getSchool); async function getSchool(req, res) { const { schoolId } = req.params; - console.log(await listCache.get("fundingGroups")) const contactTypeCodes = await listCache.get("codesList"); const fundingGroups = await listCache.get("fundingGroups"); + const url = `${config.get("server:instituteAPIURL")}/institute/school/` + schoolId; axios @@ -189,9 +189,10 @@ async function getSchool(req, res) { ); schoolData.contacts = filterByExpiryDate(schoolData.contacts); const formattedGrades = formatGrades(schoolData.grades, schoolGrades); - const schoolWithFormattedGrades = { ...schoolData, ...formattedGrades }; + const schoolWithFormattedGrades = [{ ...schoolData, ...formattedGrades }]; + const schoolsWithFundingGroups = addFundingGroups(schoolWithFormattedGrades, fundingGroups) - res.json(schoolsWithFundingGroups); + res.json(schoolsWithFundingGroups[0]); }) .catch((e) => { @@ -266,6 +267,7 @@ async function getAllSchools(req, res) { const districtList = await listCache.get("districtlist"); const schoolGrades = await codeCache.get("gradelist"); const schoolCategoryCodes = await listCache.get("categoryCodes"); + const fundingGroups = await listCache.get("fundingGroups"); const facilityCodes = await listCache.get("facilityCodes"); const url = `${config.get( "server:instituteAPIURL" @@ -309,6 +311,8 @@ async function getAllSchools(req, res) { { property: "GRADE10", label: "Grade 10 Enrollment" }, { property: "GRADE11", label: "Grade 11 Enrollment" }, { property: "GRADE12", label: "Grade 12 Enrollment" }, + { property: "fundingGroupCode", label: "Funding Group" }, + { property: "fundingGroupSubCode", label: "Funding Group Sub Code" }, ]; const mailingListpropertyOrder = [ { property: "districtNumber", label: "District Number" }, @@ -329,12 +333,14 @@ async function getAllSchools(req, res) { response.data, districtList ); - let openSchoolList = sortJSONBySchoolCode( + let openSchoolListSorted = sortJSONBySchoolCode( createSchoolCache( openSchoolListWithDistrictLabels.content, schoolGrades ) ); + + openSchoolList = addFundingGroups(openSchoolListSorted, fundingGroups) let openSchoolMailingList = [...openSchoolList]; openSchoolList = normalizeJsonObject( @@ -351,7 +357,7 @@ async function getAllSchools(req, res) { null, ["label", "description"] ); - + console.log(openSchoolList) openSchoolList.forEach((currentElement, index, array) => { const rearrangedElement = rearrangeAndRelabelObjectProperties( currentElement, diff --git a/frontend/src/views/DistrictView.vue b/frontend/src/views/DistrictView.vue index 0926111..ab56d71 100644 --- a/frontend/src/views/DistrictView.vue +++ b/frontend/src/views/DistrictView.vue @@ -135,7 +135,9 @@ onMounted(async () => { 'Phone Number': item.phoneNumber, Fax: item.faxNumber, Email: item.email, - Website: item.website + Website: item.website, + 'Funding Group': item.fundingGroupCode, + 'Funding Group SubCode': item.fundingGroupSubCode } }) filteredContacts.value = contacts.value.map((item: any) => { diff --git a/frontend/src/views/SchoolView.vue b/frontend/src/views/SchoolView.vue index ce05d42..b18f9e2 100644 --- a/frontend/src/views/SchoolView.vue +++ b/frontend/src/views/SchoolView.vue @@ -171,6 +171,7 @@ onBeforeMount(async () => { filteredContacts.value[i].GRADE11 = response.data.GRADE11 filteredContacts.value[i].GRADE12 = response.data.GRADE12 } + downloadContacts.value = transformContactForDownload(filteredContacts.value) } } @@ -257,6 +258,13 @@ function goToDistrict() { + + Funding:
+ Group: {{ schoolData.value.fundingGroupCode }}
+ Sub Group: {{ schoolData.value.fundingGroupSubCode }} +
Date: Thu, 7 Mar 2024 11:41:03 -0800 Subject: [PATCH 08/13] removed consoles --- backend/src/routes/institute-router.js | 2 -- backend/src/routes/school-router.js | 1 - 2 files changed, 3 deletions(-) diff --git a/backend/src/routes/institute-router.js b/backend/src/routes/institute-router.js index 0c381fb..5507b8a 100644 --- a/backend/src/routes/institute-router.js +++ b/backend/src/routes/institute-router.js @@ -54,7 +54,6 @@ async function createCache(req, res) { headers: { Authorization: `Bearer ${req.accessToken}` }, } ); - console.log("SET") listCache.set("fundingGroups", fundingGroupsResponse.data); res.json(fundingGroupsResponse.data); } catch (error) { @@ -320,7 +319,6 @@ async function getContactTypeCodes(req, res) { res.status(statusCode).send(error.message); } } else { - console.log("set CODELIST") const cachedCodeList = await listCache.get("codesList"); res.json(cachedCodeList); } diff --git a/backend/src/routes/school-router.js b/backend/src/routes/school-router.js index 78c228b..193d9c8 100644 --- a/backend/src/routes/school-router.js +++ b/backend/src/routes/school-router.js @@ -360,7 +360,6 @@ async function getAllSchools(req, res) { null, ["label", "description"] ); - console.log(openSchoolList) openSchoolList.forEach((currentElement, index, array) => { const rearrangedElement = rearrangeAndRelabelObjectProperties( currentElement, From c1ef589d58bb3a22a7fc8e826153836d5e509878 Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Thu, 7 Mar 2024 12:02:38 -0800 Subject: [PATCH 09/13] updated the types --- frontend/src/types/types.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/types/types.d.ts b/frontend/src/types/types.d.ts index d59e444..99e7a58 100644 --- a/frontend/src/types/types.d.ts +++ b/frontend/src/types/types.d.ts @@ -131,6 +131,8 @@ export interface School { grades: Grade[]; contacts: SchoolContact[]; addresses: Address[]; + fundingGroupSubCode: string; + fundingGroupCode: string; notes?: []; } From 476f0337447b7c77676c0a2ecac169c3c7327fb4 Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Thu, 7 Mar 2024 12:26:12 -0800 Subject: [PATCH 10/13] updated the config map for schools api --- tools/config/update-configmap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/config/update-configmap.sh b/tools/config/update-configmap.sh index 63d0c2e..d739bf5 100644 --- a/tools/config/update-configmap.sh +++ b/tools/config/update-configmap.sh @@ -29,7 +29,7 @@ then fi echo Creating config map $APP_NAME-backend-config-map -oc create -n $OPENSHIFT_NAMESPACE-$envValue configmap $APP_NAME-backend-config-map --from-literal=TZ=$TZVALUE --from-literal=BANNER_COLOR=$bannerColor --from-literal=BANNER_ENVIRONMENT=$bannerEnvironment --from-literal=SOAM_CLIENT_ID=$KC_CLIENT_SECRET --from-literal=SOAM_TOKEN_URL=$KC_TOKEN_URL --from-literal=SOAM_CLIENT_SECRET=$KC_CLIENT_ID --from-literal=CLEAR_FILES_KEY=$CLEAR_FILES_KEY --from-literal=SERVER_FRONTEND="$SERVER_FRONTEND" --from-literal=INSTITUTE_API_URL="http://institute-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/api/v1" --from-literal=INSTITUTE_API_EXPIRY=300 --from-literal=LOG_LEVEL=info --from-literal=NODE_ENV="openshift" --dry-run -o yaml | oc apply -f - +oc create -n $OPENSHIFT_NAMESPACE-$envValue configmap $APP_NAME-backend-config-map --from-literal=TZ=$TZVALUE --from-literal=BANNER_COLOR=$bannerColor --from-literal=BANNER_ENVIRONMENT=$bannerEnvironment --from-literal=SOAM_CLIENT_ID=$KC_CLIENT_SECRET --from-literal=SOAM_TOKEN_URL=$KC_TOKEN_URL --from-literal=SOAM_CLIENT_SECRET=$KC_CLIENT_ID --from-literal=CLEAR_FILES_KEY=$CLEAR_FILES_KEY --from-literal=SERVER_FRONTEND="$SERVER_FRONTEND" --from-literal=INSTITUTE_API_URL="http://institute-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/api/v1" --from-literal=SCHOOLS_API_URL="http://schools-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/api/v1" --from-literal=INSTITUTE_API_EXPIRY=300 --from-literal=LOG_LEVEL=info --from-literal=NODE_ENV="openshift" --dry-run -o yaml | oc apply -f - echo echo Setting environment variables for $APP_NAME-backend-$SOAM_KC_REALM_ID application oc -n $OPENSHIFT_NAMESPACE-$envValue set env --from=configmap/$APP_NAME-backend-config-map dc/$APP_NAME-backend-main From 417900fd878ad508768f5324b0ac34a106a3ca45 Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Thu, 7 Mar 2024 12:33:15 -0800 Subject: [PATCH 11/13] fixed school endpoint config --- tools/config/update-configmap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/config/update-configmap.sh b/tools/config/update-configmap.sh index d739bf5..e148a04 100644 --- a/tools/config/update-configmap.sh +++ b/tools/config/update-configmap.sh @@ -29,7 +29,7 @@ then fi echo Creating config map $APP_NAME-backend-config-map -oc create -n $OPENSHIFT_NAMESPACE-$envValue configmap $APP_NAME-backend-config-map --from-literal=TZ=$TZVALUE --from-literal=BANNER_COLOR=$bannerColor --from-literal=BANNER_ENVIRONMENT=$bannerEnvironment --from-literal=SOAM_CLIENT_ID=$KC_CLIENT_SECRET --from-literal=SOAM_TOKEN_URL=$KC_TOKEN_URL --from-literal=SOAM_CLIENT_SECRET=$KC_CLIENT_ID --from-literal=CLEAR_FILES_KEY=$CLEAR_FILES_KEY --from-literal=SERVER_FRONTEND="$SERVER_FRONTEND" --from-literal=INSTITUTE_API_URL="http://institute-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/api/v1" --from-literal=SCHOOLS_API_URL="http://schools-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/api/v1" --from-literal=INSTITUTE_API_EXPIRY=300 --from-literal=LOG_LEVEL=info --from-literal=NODE_ENV="openshift" --dry-run -o yaml | oc apply -f - +oc create -n $OPENSHIFT_NAMESPACE-$envValue configmap $APP_NAME-backend-config-map --from-literal=TZ=$TZVALUE --from-literal=BANNER_COLOR=$bannerColor --from-literal=BANNER_ENVIRONMENT=$bannerEnvironment --from-literal=SOAM_CLIENT_ID=$KC_CLIENT_SECRET --from-literal=SOAM_TOKEN_URL=$KC_TOKEN_URL --from-literal=SOAM_CLIENT_SECRET=$KC_CLIENT_ID --from-literal=CLEAR_FILES_KEY=$CLEAR_FILES_KEY --from-literal=SERVER_FRONTEND="$SERVER_FRONTEND" --from-literal=INSTITUTE_API_URL="http://institute-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/api/v1" --from-literal=SCHOOLS_API_URL="http://school-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/api/v1" --from-literal=INSTITUTE_API_EXPIRY=300 --from-literal=LOG_LEVEL=info --from-literal=NODE_ENV="openshift" --dry-run -o yaml | oc apply -f - echo echo Setting environment variables for $APP_NAME-backend-$SOAM_KC_REALM_ID application oc -n $OPENSHIFT_NAMESPACE-$envValue set env --from=configmap/$APP_NAME-backend-config-map dc/$APP_NAME-backend-main From 4faffb3c2e5ec3dcc48f07334d93bdf58865be9c Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Thu, 7 Mar 2024 13:21:26 -0800 Subject: [PATCH 12/13] added funding groups to search --- backend/src/routes/search-router.js | 7 +++++-- frontend/src/views/SchoolSearchView.vue | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/src/routes/search-router.js b/backend/src/routes/search-router.js index 5bf8b92..85b9b8b 100644 --- a/backend/src/routes/search-router.js +++ b/backend/src/routes/search-router.js @@ -8,15 +8,18 @@ const fs = require("fs"); const path = require("path"); const { checkToken } = require("../components/auth"); const { listCache } = require("../components/cache"); -const {appendMailingAddressDetailsAndRemoveAddresses, rearrangeAndRelabelObjectProperties, sortByProperty} = require("../components/utils.js") +const {addFundingGroups, appendMailingAddressDetailsAndRemoveAddresses, rearrangeAndRelabelObjectProperties, sortByProperty} = require("../components/utils.js") //Batch Routes router.get("/*", checkToken, getSearchResults) async function getSearchResults(req, res) { - + const fundingGroups = await listCache.get("fundingGroups") const url = `${config.get("server:instituteAPIURL")}`+ req.url; axios .get(url, { headers: { Authorization: `Bearer ${req.accessToken}` } }) .then((response) => { + const results = response.data.content; + const resultsWithFundingGroups = addFundingGroups(results, fundingGroups); + response.data.content = resultsWithFundingGroups; res.json(response.data); }) .catch((e) => { diff --git a/frontend/src/views/SchoolSearchView.vue b/frontend/src/views/SchoolSearchView.vue index c7c24c9..c4a1a74 100644 --- a/frontend/src/views/SchoolSearchView.vue +++ b/frontend/src/views/SchoolSearchView.vue @@ -328,6 +328,11 @@ onBeforeMount(async () => { + + Funding
+ Group: {{ item.fundingGroupCode }}
+ Sub Group: {{ item.fundingGroupSubCode }} +
From fd3678679607380ac6b383ff3061ae17311208ce Mon Sep 17 00:00:00 2001 From: Shaun Lum Date: Thu, 7 Mar 2024 21:25:51 -0800 Subject: [PATCH 13/13] merged with main --- backend/src/components/utils.js | 52 ++++++++++--------- backend/src/routes/school-router.js | 4 +- .../src/components/common/DisplayAlert.vue | 8 +-- frontend/src/types/types.d.ts | 1 - frontend/src/views/DistrictView.vue | 3 +- frontend/src/views/SchoolSearchView.vue | 3 +- frontend/src/views/SchoolView.vue | 5 +- 7 files changed, 37 insertions(+), 39 deletions(-) diff --git a/backend/src/components/utils.js b/backend/src/components/utils.js index b583a90..65ff6c2 100644 --- a/backend/src/components/utils.js +++ b/backend/src/components/utils.js @@ -275,33 +275,37 @@ function addDistrictLabels(jsonData, districtList) { return nonPubliclyAvailableCodes; } function addFundingGroups(schools, fundingGroups) { - // Process each school in the array - - const schoolsWithFunding = schools.map(school => { - // Find the corresponding funding group by mincode - const matchingFundingGroup = fundingGroups.find(fundingGroup => - fundingGroup.mincode === school.mincode - ); + try { + // Process each school in the array + const schoolsWithFunding = schools.map(school => { + // Find the corresponding funding group by mincode + const matchingFundingGroup = fundingGroups.find(fundingGroup => + fundingGroup.mincode === school.mincode + ); + // Add fundingGroupCode to the school + if (matchingFundingGroup) { + Object.assign(school, { + fundingGroupCode: matchingFundingGroup.fundingGroupCode, + }); + } else { + // If mincode is not found in fundingGroups, add null values + Object.assign(school, { + fundingGroupCode: null, + }); + } - // Add fundingGroupCode and fundingGroupSubCode to the school - if (matchingFundingGroup) { - Object.assign(school, { - fundingGroupCode: matchingFundingGroup.fundingGroupCode, - fundingGroupSubCode: matchingFundingGroup.fundingGroupSubCode, - }); - } else { - // If mincode is not found in fundingGroups, add null values - Object.assign(school, { - fundingGroupCode: null, - fundingGroupSubCode: null, - }); - } + return school; + }); - return school; - }); - return schoolsWithFunding; -} + return schoolsWithFunding; + } catch (error) { + // Handle the error here, you can log it or perform other actions + console.error("An error occurred in addFundingGroups:", error); + // Optionally, you can rethrow the error if needed + throw error; + } + } function getArrayofPubliclyAvailableCodes(codes, field) { if (!Array.isArray(codes)) { throw new Error('Invalid input. Expecting an array of objects.'); diff --git a/backend/src/routes/school-router.js b/backend/src/routes/school-router.js index 79a8a28..b6908be 100644 --- a/backend/src/routes/school-router.js +++ b/backend/src/routes/school-router.js @@ -315,7 +315,6 @@ async function getAllSchools(req, res) { { property: "GRADE11", label: "Grade 11 Enrollment" }, { property: "GRADE12", label: "Grade 12 Enrollment" }, { property: "fundingGroupCode", label: "Funding Group" }, - { property: "fundingGroupSubCode", label: "Funding Group Sub Code" }, ]; const mailingListpropertyOrder = [ { property: "districtNumber", label: "District Number" }, @@ -331,7 +330,6 @@ async function getAllSchools(req, res) { { property: "physical_postal", label: "Courier Postal Code" }, { property: "phoneNumber", label: "Phone" }, ]; - const openSchoolListWithDistrictLabels = addDistrictLabels( response.data, districtList @@ -353,6 +351,7 @@ async function getAllSchools(req, res) { null, ["label", "description"] ); + openSchoolList = normalizeJsonObject( openSchoolList, facilityCodes, @@ -402,7 +401,6 @@ async function getAllSchools(req, res) { schoolCache.set("openschoollistALL", openSchoolList); schoolCache.set("openschoollistALLMAILING", openSchoolMailingList); - if (schoolCategory == "INDEPEND") { res.json(openINDEPENDSchoolList); } else if (schoolCategory == "PUBLIC") { diff --git a/frontend/src/components/common/DisplayAlert.vue b/frontend/src/components/common/DisplayAlert.vue index 2b5f8ac..e273514 100644 --- a/frontend/src/components/common/DisplayAlert.vue +++ b/frontend/src/components/common/DisplayAlert.vue @@ -4,8 +4,10 @@ The information on this page is provided by schools and districts through the Education Data Exchange (EDX). - Learn more.Learn more. +
If you represent an Independent School or Independent Authority and have not yet been + onboarded to EDX, please email + Independent Schools Office to + update your contact information. diff --git a/frontend/src/types/types.d.ts b/frontend/src/types/types.d.ts index 99e7a58..14ac2fa 100644 --- a/frontend/src/types/types.d.ts +++ b/frontend/src/types/types.d.ts @@ -131,7 +131,6 @@ export interface School { grades: Grade[]; contacts: SchoolContact[]; addresses: Address[]; - fundingGroupSubCode: string; fundingGroupCode: string; notes?: []; } diff --git a/frontend/src/views/DistrictView.vue b/frontend/src/views/DistrictView.vue index 405facd..24ad010 100644 --- a/frontend/src/views/DistrictView.vue +++ b/frontend/src/views/DistrictView.vue @@ -138,8 +138,7 @@ onMounted(async () => { Fax: item.faxNumber, Email: item.email, Website: item.website, - 'Funding Group': item.fundingGroupCode, - 'Funding Group SubCode': item.fundingGroupSubCode + 'Funding Group': item.fundingGroupCode } }) filteredContacts.value = contacts.value.map((item: any) => { diff --git a/frontend/src/views/SchoolSearchView.vue b/frontend/src/views/SchoolSearchView.vue index 1e22459..fe65454 100644 --- a/frontend/src/views/SchoolSearchView.vue +++ b/frontend/src/views/SchoolSearchView.vue @@ -331,10 +331,9 @@ onBeforeMount(async () => { - + Funding
Group: {{ item.fundingGroupCode }}
- Sub Group: {{ item.fundingGroupSubCode }}
diff --git a/frontend/src/views/SchoolView.vue b/frontend/src/views/SchoolView.vue index 05e5b38..60137c6 100644 --- a/frontend/src/views/SchoolView.vue +++ b/frontend/src/views/SchoolView.vue @@ -260,12 +260,9 @@ function goToDistrict() { - + Funding:
Group: {{ schoolData.value.fundingGroupCode }}
- Sub Group: {{ schoolData.value.fundingGroupSubCode }}