-
Couldn't load subscription status.
- Fork 0
[TM-2478] Polygon Size and Estimated Area validators #314
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-2478] Polygon Size and Estimated Area validators #314
Conversation
…ated-area-validators
…te-validators' into feat/TM-2478-polygon-size-estimated-area-validators
…te-validators' into feat/TM-2478-polygon-size-estimated-area-validators
…te-validators' into feat/TM-2478-polygon-size-estimated-area-validators
…te-validators' into feat/TM-2478-polygon-size-estimated-area-validators
| lowerBoundProject: number | null; | ||
| upperBoundProject: number | null; | ||
| }> { | ||
| const site = sitePolygon.site != null ? sitePolygon.site : await sitePolygon.loadSite(); |
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.
The loadSite method does these checks for you, so this can simply be
const site = await sitePolygon.loadSite();
If it's already been loaded, it'll return immediately.
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.
Fixed redundant null check for loadSite() method.
| const siteUuids = sites.map(site => site.uuid); | ||
| const result = await SitePolygon.sum("calcArea", { | ||
| where: { | ||
| siteUuid: siteUuids, |
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 should be handled with a subquery instead of the findAll above. Should this be using only approved sites? If so, there's one already ready for you to use (approvedUuidsSubquery). If not, you can add this to Site and use it:
static uuidsSubquery(projectId: number) {
return Subquery.select(Site, "uuid").eq("projectId", projectId).literal;
}
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.
Added uuidsSubquery method to the Site entity.
https://gfw.atlassian.net/browse/TM-2478