-
Notifications
You must be signed in to change notification settings - Fork 81
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
Conversation
Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:
|
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')) | ||
} |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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) |
There was a problem hiding this comment.
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
setStateOrCountrySelected(isStateOrCountrySelected(selectedLocation)) | ||
}, [ | ||
selectedLocation, | ||
isAccessibleOfficeSelected, | ||
isOfficeSelected, | ||
isStateOrCountrySelected | ||
]) |
There was a problem hiding this comment.
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
// 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 |
There was a problem hiding this comment.
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
Description
Issue #8092
Checklist