Skip to content

remove completeness component for lower locations #9685

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

Merged
merged 6 commits into from
Jun 17, 2025

Conversation

bvenceslas
Copy link
Contributor

@bvenceslas bvenceslas commented Jun 2, 2025

Description

Issue #8092

Checklist

  • I have linked the correct Github issue under "Development"
  • I have tested the changes locally, and written appropriate tests
  • I have tested beyond the happy path (e.g. edge cases, failure paths)
  • I have updated the changelog with this change (if applicable)
  • I have updated the GitHub issue status accordingly

Copy link

github-actions bot commented Jun 2, 2025

Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:

  • Changelog is read by country implementors who might not always be familiar with all technical details of OpenCRVS. Keep language high-level, user friendly and avoid technical references to internals.
  • Answer "What's new?", "Why was the change made?" and "Why should I care?" for each change.
  • If it's a breaking change, include a migration guide answering "What do I need to do to upgrade?".

@ocrvs-bot
Copy link
Contributor

Your environment is deployed to https://ocrvs-8092.opencrvs.dev

locationNodeMap.get('0')!.children.forEach((childId) => validateTree(childId))
if (statisticsErrors.length > 0) {
raise(statisticsErrors.map((error) => error.message).join('\n'))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@bvenceslas Correct me if I am wrong but the goal was to remove the requirement for all lower level locations to have statistics data but we still want to ensure that the top level locations i.e. the states have statistics data. But the current change removes any and all statistics validations

)?.code === 'CRVS_OFFICE'
)
function isState(location: Location) {
return location.identifier?.find((district) => district.value === 'STATE')
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return location.identifier?.find((district) => district.value === 'STATE')
return location.identifier?.find(({ value }) => value === 'STATE')

The identifiers aren't really districts so let's not name them as such

Comment on lines 97 to 100
male_population: Joi.number().min(0).default(0),
female_population: Joi.number().min(0).default(0),
population: Joi.number().min(0).default(0),
crude_birth_rate: Joi.number().min(0).default(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to make these properties optional as they refer to a "single" statistics value. If you take a look here at the "requestLocationSchema" https://github.com/opencrvs/opencrvs-core/blob/release-v1.8.0/packages/config/src/handlers/locations/handler.ts#L126-L129, the statistics property has always been optional.

In short, if you don't want to provide statistics data for a location that's fine, but if you do provide it then it should have all these fields present

Comment on lines 323 to 329
setStateOrCountrySelected(isStateOrCountrySelected(selectedLocation))
}, [
selectedLocation,
isAccessibleOfficeSelected,
isOfficeSelected,
isStateOrCountrySelected
])
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't need to be a state at all. It can just be a derived value from selectedLocation. You could perhaps use useMemo if you really want but no need for it to be a separate state

Comment on lines 154 to 165
// Add statistics without validation
femalePopulations.push({
[data.year]: data.female_population
[data.year]: data.female_population || 0
})
malePopulations.push({
[data.year]: data.male_population
[data.year]: data.male_population || 0
})
totalPopulations.push({
[data.year]: data.population
[data.year]: data.population || 0
})
birthRates.push({
[data.year]: data.crude_birth_rate
[data.year]: data.crude_birth_rate || 0
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes will become unnecessary if we revert the changes made to the schema

@bvenceslas bvenceslas added this to the v1.8.0 milestone Jun 17, 2025
@bvenceslas bvenceslas merged commit 61b06b5 into release-v1.8.0 Jun 17, 2025
115 of 118 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants