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

RN-603 de dg multi mapping #4081

Closed
wants to merge 15 commits into from
Closed

RN-603 de dg multi mapping #4081

wants to merge 15 commits into from

Conversation

IgorNadj
Copy link
Contributor

@IgorNadj IgorNadj commented Aug 9, 2022

Issue #: RN-603

Changes:

  • Add ability to map a single Data Element / Data Group to multiple data services based on country fetched for

Copy link
Collaborator

@rohan-bes rohan-bes left a comment

Choose a reason for hiding this comment

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

Really nice work man! Love how simple this was to implement 👍

One general request, looks like with the implementation where this is a separate column, it can't be configured via the Admin Panel? I'd really love if that were possible (anything to avoid needing more migrations)

Thoughts on either moving the dataServiceMapping into the config field, or adding the appropriate boilerplate to allow configuring this as part of the Admin Panel?

Aside from that just some minor code style comments, but nothing major. Love the tests btw 👍

};

exports.up = async function (db) {
await db.runSql(`ALTER TABLE data_element ADD COLUMN data_service_mapping JSONB DEFAULT '[]'`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a major thing, and we are planning on removing this in the long run anyway, but I guess I had supposed this would be part of the config attribute? Given it's going to be used so rarely, seems it mightn't warrant a column of its own?

};

const entity = orgUnitCode ? await this.models.entity.findOne({ code: orgUnitCode }) : null;
const { countryCode } = entity ?? {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to throw an error here if we can't find an entity/countryCode? Feels a tad unsafe that we could follow through to to the below logic with a undefined countryCode.

Bit on the fence but just wanted to raise it

Comment on lines 310 to 313
if (!map[serviceType]) {
map[serviceType] = [];
}
addToMap(serviceType, dataSource);
Copy link
Collaborator

@rohan-bes rohan-bes Aug 12, 2022

Choose a reason for hiding this comment

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

Suggested change
if (!map[serviceType]) {
map[serviceType] = [];
}
addToMap(serviceType, dataSource);
addToMap(serviceType, dataSource);

I think your nifty addToMap() function handles the case if there's no entry for the service type 👍

@IgorNadj
Copy link
Contributor Author

@rohan-bes Thanks for the review, I'm going to have to rework this to handle both country level and individual entities, will ping when ready again

@IgorNadj IgorNadj force-pushed the rn-603-de-dg-multi-mapping branch from f14208a to d29a9da Compare September 6, 2022 07:29
@IgorNadj
Copy link
Contributor Author

IgorNadj commented Sep 6, 2022

Closing this, will re-create PR and link back so we don't lose feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants