related org append / remove#436
Merged
joffinjoy merged 7 commits intoELEVATE-Project:developfrom Mar 14, 2024
Merged
Conversation
…o working-branch
joffinjoy
reviewed
Mar 13, 2024
src/services/organization.js
Outdated
| // update parent org related orgs | ||
| const parentOrganzationUpdate = await organizationQueries.update( | ||
| { | ||
| id: id, |
Collaborator
There was a problem hiding this comment.
This is just a sylistic thing. you can simply mention this as {id} instead of { id:id}. Valid only when the key and variable from which the value is set are both with the same name.
joffinjoy
reviewed
Mar 13, 2024
src/services/organization.js
Outdated
| ) | ||
|
|
||
| // update child org related orgs | ||
| const childOrganzationUpdate = await organizationQueries.removeRelatedOrg(id, relatedOrgs, { |
Collaborator
There was a problem hiding this comment.
Rename this as relatedOrganizationsUpdate. There are no child organizations as of right now.
joffinjoy
reviewed
Mar 13, 2024
src/services/organization.js
Outdated
| static async addRelatedOrg(id, relatedOrgs) { | ||
| try { | ||
| // fetch organization details before update | ||
| const orgDetailsBeforeUpdate = await organizationQueries.findOne({ id: id }) |
joffinjoy
reviewed
Mar 13, 2024
| message: 'ORGANIZATION_NOT_FOUND', | ||
| }) | ||
| } | ||
|
|
Collaborator
There was a problem hiding this comment.
throw an error the request tries to remove an organization that doesn't exist as a related org to the parent org.
joffinjoy
reviewed
Mar 13, 2024
src/services/organization.js
Outdated
| // check if there are any addition to related_org | ||
| if (!_.isEqual(orgDetailsBeforeUpdate?.related_orgs, relatedOrganizations)) { | ||
| // update parent org related orgs | ||
| const parentOrganzationUpdate = await organizationQueries.update( |
Collaborator
There was a problem hiding this comment.
rename this as currentOrganizationUpdate. parent and child can be confusing later on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.