Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent loading when navigating to District and Authority nodes via URL #166

Merged
merged 5 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 35 additions & 36 deletions backend/src/routes/district-router.js
Original file line number Diff line number Diff line change
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 @@ -399,8 +396,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 @@ -410,36 +408,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
Loading