-
Notifications
You must be signed in to change notification settings - Fork 0
[TM-2084] Move demographics new controller and support querying #194
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
[TM-2084] Move demographics new controller and support querying #194
Conversation
…rvice and controller for new structure
…project report filtering
…figure yarn settings
…e report filtering
…upport querying by project and site reports
…new-controller-and-support-querying
… enhance query capabilities
…rying and validation
…roved readability and maintainability
…new-controller-and-support-querying
…ructor for additional data retrieval
…for DemographicPolicy entry
where: { id: demographic.demographicalId }, | ||
attributes: ["id", "uuid"] | ||
}); | ||
const demographicDto = new DemographicDto(demographic, demographicData); |
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 demographicData
isn't the right shape. I'm a little surprised it compiles... it's been tricky getting the type safety guards right on those DTOs. It should look like this (example from the association processor that is also creating this DTO):
terramatch-microservices/apps/entity-service/src/entities/processors/association-processor.ts
Line 72 in f6ddd71
const additionalProps = { entityType: this.entityType, entityUuid: this.entityUuid }; |
I'm also surprised it's not complaining that model
could be null. In this case, something like this should be right:
const { demographicalType: entityType, demographicalId } = demographic;
const model = LARAVEL_MODELS[entityType];
if (model == null) {
this.logger.error('Unknown model type', entityType);
throw new InternalServerErrorException('Unexpected demographic association type');
}
const entity = await model.findOne({ where: { id: demographicalId }, attributes: ["uuid"] });
if (entity == null) {
this.logger.error('Demographic parent entity not found', { entityType, id: demographicalId });
throw new NotFoundException();
}
const additionalProps = { entityType, entityUuid: entity.uuid };
const demographicDto = new DemographicDto(demographic, additionalProps);
…new-controller-and-support-querying
…ing for demographic entity retrieval
…PES for demographicalType mapping and add Project to Demographic import
…tFactory for demographic ID assignment and improve error logging
…demographic associations and improve type definitions
https://gfw.atlassian.net/browse/TM-2084