Skip to content

Commit

Permalink
fix: org number
Browse files Browse the repository at this point in the history
  • Loading branch information
dadiorchen committed Oct 8, 2022
1 parent 15a7873 commit 0426228
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/infra/database/TreeRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export default class TreeRepository extends BaseRepository<Tree> {
COUNT(*)
FROM trees
LEFT JOIN planter ON trees.planter_id = planter.id
LEFT JOIN entity ON entity.id = planter.organization_id
WHERE entity.id = ${organization_id}
WHERE
planter.organization_id in ( SELECT entity_id from getEntityRelationshipChildren(${organization_id}))
`;
const total = await this.session.getDB().raw(totalSql);
return parseInt(total.rows[0].count.toString());
Expand All @@ -87,7 +87,8 @@ export default class TreeRepository extends BaseRepository<Tree> {
LEFT JOIN region
on ST_WITHIN(trees.estimated_geometric_location, region.geom)
and region.type_id in (select id from region_type where type = 'country')
WHERE entity.id = ${organization_id}
WHERE
planter.organization_id in ( SELECT entity_id from getEntityRelationshipChildren(${organization_id}))
LIMIT ${limit}
OFFSET ${offset}
`;
Expand Down

0 comments on commit 0426228

Please sign in to comment.