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

Patch 3 #740

Merged
merged 14 commits into from
May 29, 2024
Merged
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
6 changes: 3 additions & 3 deletions utilities/project-factory/src/server/utils/genericUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,10 +746,10 @@ function modifyBoundaryData(boundaryData: unknown[], localizationMap?: any) {
boundaryData.forEach((obj: any) => {
// Convert object entries to an array of {key, value} objects
const row: any = Object.entries(obj)
.filter(([key, value]) => value !== null && value !== undefined)
.map(([key, value]) => ({ key, value }));
.filter(([key, value]) => key !== getLocalizedName(config?.boundary?.boundaryCode,localizationMap) && value !== null && value !== undefined)
.map(([key, value]: [string, any]) => ({ key, value: value.toString().replace(/_/g, ' ').trim() }));
Comment on lines +749 to +750
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor modifyBoundaryData to enhance readability and maintainability.

- .filter(([key, value]) =>  key !== getLocalizedName(config?.boundary?.boundaryCode,localizationMap) && value !== null && value !== undefined)
- .map(([key, value]: [string, any]) => ({ key, value: value.toString().replace(/_/g, ' ').trim() }));
+ .filter(([key, value]) => key !== getLocalizedName(config?.boundary?.boundaryCode, localizationMap) && value != null)
+ .map(([key, value]: [string, any]) => ({ key, value: value.toString().replace(/_/g, ' ').trim() }));

Consider using != null to check for both null and undefined in a more concise manner. Also, ensure consistent spacing around operators for better readability.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
.filter(([key, value]) => key !== getLocalizedName(config?.boundary?.boundaryCode,localizationMap) && value !== null && value !== undefined)
.map(([key, value]: [string, any]) => ({ key, value: value.toString().replace(/_/g, ' ').trim() }));
.filter(([key, value]) => key !== getLocalizedName(config?.boundary?.boundaryCode, localizationMap) && value != null)
.map(([key, value]: [string, any]) => ({ key, value: value.toString().replace(/_/g, ' ').trim() }));


// Determine whether the object has a boundary code property
// Determine whether the object has a boundary code property
const hasBoundaryCode = obj.hasOwnProperty(getLocalizedName(config?.boundary?.boundaryCode, localizationMap));

// Push the row to the appropriate array based on whether it has a boundary code property
Expand Down
Loading