diff --git a/backend/src/database/repositories/organizationRepository.ts b/backend/src/database/repositories/organizationRepository.ts index 2de5c28c3..ba2473fa7 100644 --- a/backend/src/database/repositories/organizationRepository.ts +++ b/backend/src/database/repositories/organizationRepository.ts @@ -1685,7 +1685,9 @@ class OrganizationRepository { ? ` INNER JOIN "organizationSegmentsAgg" osa ON osa."organizationId" = o.id AND ${ segmentId ? `osa."segmentId" = $(segmentId)` : `osa."segmentId" IS NULL` }` - : '' + : ` LEFT JOIN "organizationSegmentsAgg" osa ON osa."organizationId" = o.id AND ${ + segmentId ? `osa."segmentId" = $(segmentId)` : `osa."segmentId" IS NULL` + }` } WHERE 1=1 AND o."tenantId" = $(tenantId) diff --git a/backend/src/services/organizationService.ts b/backend/src/services/organizationService.ts index 492928cdf..7e94e87a8 100644 --- a/backend/src/services/organizationService.ts +++ b/backend/src/services/organizationService.ts @@ -1022,7 +1022,7 @@ export default class OrganizationService extends LoggerBase { offset, segmentId: segments.length > 0 ? segments[0] : undefined, fields: ['id', 'segmentId', 'displayName', 'memberCount', 'activityCount', 'logo'], - include: { aggregates: true, identities: false, lfxMemberships: true }, + include: { aggregates: false, identities: false, lfxMemberships: true }, }, this.options, )