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

[OCRVS-6124] Fix locations seeding when there are many locations #6399

Merged
merged 12 commits into from
Feb 12, 2024

Conversation

tahmidrahman-dsi
Copy link
Collaborator

No description provided.

}
})
const response: fhir3.Bundle<fhir3.BundleEntryResponse> = await res.json()
Copy link
Collaborator

Choose a reason for hiding this comment

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

@tahmidrahman-dsi The issue might be that we need to resolve the partOf values of the district locations with that of the actual values we get from hearth after creating the states.

Copy link
Collaborator

@Zangetsu101 Zangetsu101 Jan 3, 2024

Choose a reason for hiding this comment

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

and these level by level segmentation might need to be moved to the actual handler in gateway due to this reason

}
return fetchFromHearth('', 'POST', JSON.stringify(locationsBundle))
return h.response().code(201)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be possible to do this in createLocationHandler so Hapi related code wouldn't leak to this function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, @rikukissa, I am on it

Comment on lines 191 to 205
function createLocationSegments(locations: Location[]): Location[][] {
const segments = []
for (const jurisdictionType of Object.keys(JurisdictionType)) {
const jurisdictionLocations = locations.filter(
(loc) => loc.jurisdictionType === jurisdictionType
)
if (jurisdictionLocations.length) {
segments.push(jurisdictionLocations)
}
}
const facilitiesOrOffices = locations.filter((loc) => !loc.jurisdictionType)
if (facilitiesOrOffices.length) {
segments.push(facilitiesOrOffices)
}
return segments
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't remember exactly but my recollection is the majority of locations in Cameroon are offices. Would this approach be sufficient if a country has lets say 90% offices? Would a numeric limit segmentation be more reliable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, I am also seeing not much significant difference in the case of Madagascar, I am going to add a numeric limit to the batch items

locations: Location[],
h: Hapi.ResponseToolkit
) {
let parentLocationsMap: Map<string, string> = new Map()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you clarify this parentLocationMap a bit. I don't understand what it does 😞

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

parentLocationsMap has statistical id to fhirId mapping of parent locations, I agree, I should give it more clearer name. I am thinking to change it statisticalToFhirIDMapOfParentLocations

Comment on lines +201 to +205
function createLocationSegments(locations: Location[]): Location[][] {
const segments = []
for (const jurisdictionType of Object.keys(JurisdictionType)) {
const jurisdictionLocations = locations.filter(
(loc) => loc.jurisdictionType === jurisdictionType
)
if (jurisdictionLocations.length) {
segments.push(...createChunks(jurisdictionLocations, LOCATION_CHUNK_SIZE))
}
}
const facilitiesOrOffices = locations.filter((loc) => !loc.jurisdictionType)
if (facilitiesOrOffices.length) {
segments.push(...createChunks(facilitiesOrOffices, LOCATION_CHUNK_SIZE))
}
return segments
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This logic is probably not needed anymore now that you implemented the length based approach, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agreed, just putting the admin locations first would be sufficient

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, @rikukissa I think it should stay the same, as I am updating the statisticalToFhirIDMap after processing each segment. If we remove this jurisdiction-type filtering logic, there will be a chance of staying parent and child locations in the same segment. Then the fhirID of the parent location cannot be resolved as the map will not already be updated

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to first, right in the beginning the whole process, create the full parent map from all locations? @tahmidrahman-dsi

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I cannot think of any way of doing it 🤔 ... because I cannot get the fhirIDs before sending them to hearth

Copy link
Collaborator

Choose a reason for hiding this comment

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

Annoying! Yea, you are right. It's not as easy as I thought. In that case this looks good to me 👍

@tahmidrahman-dsi tahmidrahman-dsi changed the base branch from develop to release-v1.3.3 January 10, 2024 09:42
Copy link

codecov bot commented Jan 11, 2024

Codecov Report

Attention: 35 lines in your changes are missing coverage. Please review.

Comparison is base (429d530) 86.33% compared to head (7d3cc21) 86.31%.
Report is 7 commits behind head on release-v1.3.3.

❗ Current head 7d3cc21 differs from pull request most recent head 0aafa52. Consider uploading reports for the commit 0aafa52 to get more accurate results

Files Patch % Lines
...teway/src/features/restLocation/locationHandler.ts 2.77% 35 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           release-v1.3.3    #6399      +/-   ##
==================================================
- Coverage           86.33%   86.31%   -0.02%     
==================================================
  Files                 728      728              
  Lines              126747   126613     -134     
  Branches            12045    11967      -78     
==================================================
- Hits               109424   109292     -132     
+ Misses              17318    17316       -2     
  Partials                5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@rikukissa rikukissa left a comment

Choose a reason for hiding this comment

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

Tested locally with 10 000 offices and the issue seems to be fixed

@Zangetsu101 Zangetsu101 added 💥 Hot Fixes Hot fixes for (prod/qa/staging) deployment ✅ Ready for merging labels Jan 18, 2024
@euanmillar euanmillar merged commit 04ec0c4 into release-v1.3.3 Feb 12, 2024
1 check passed
@euanmillar euanmillar deleted the ocrvs-6124 branch February 12, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💥 Hot Fixes Hot fixes for (prod/qa/staging) deployment ✅ Ready for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants