Skip to content

Conversation

@cesarLima1
Copy link
Collaborator

Base automatically changed from feat/TM-2489-complete-data-and-plant-start-date-validators to release/opulent-opal September 30, 2025 14:25
lowerBoundProject: number | null;
upperBoundProject: number | null;
}> {
const site = sitePolygon.site != null ? sitePolygon.site : await sitePolygon.loadSite();
Copy link
Collaborator

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.

Copy link
Collaborator Author

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,
Copy link
Collaborator

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;
  }

Copy link
Collaborator Author

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.

@cesarLima1 cesarLima1 requested a review from roguenet October 1, 2025 15:07
@cesarLima1 cesarLima1 merged commit 9589f96 into release/opulent-opal Oct 1, 2025
1 check passed
@cesarLima1 cesarLima1 deleted the feat/TM-2478-polygon-size-estimated-area-validators branch October 1, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants