@@ -1152,21 +1152,19 @@ class OrganizationRepository {
1152
1152
const query = `
1153
1153
with leaf_segment_ids as (${ segmentsSubQuery } ),
1154
1154
member_data as (select a."organizationId",
1155
- count(distinct m.id) filter ( where mo."dateEnd" is null ) as "memberCount",
1155
+ count(distinct a."memberId") as "memberCount",
1156
1156
count(distinct a.id) as "activityCount",
1157
1157
case
1158
1158
when array_agg(distinct a.platform) = array [null] then array []::text[]
1159
1159
else array_agg(distinct a.platform) end as "activeOn",
1160
1160
max(a.timestamp) as "lastActive",
1161
1161
min(a.timestamp) filter ( where a.timestamp <> '1970-01-01T00:00:00.000Z' ) as "joinedAt"
1162
1162
from leaf_segment_ids ls
1163
- left join activities a
1163
+ join activities a
1164
1164
on a."segmentId" = ls.id and a."organizationId" = :id and
1165
1165
a."deletedAt" is null
1166
- left join members m on a."memberId" = m.id and m."deletedAt" is null
1167
- left join "memberOrganizations" mo
1168
- on m.id = mo."memberId" and mo."organizationId" = :id
1169
- left join "memberIdentities" mi on m.id = mi."memberId"
1166
+ join members m on a."memberId" = m.id and m."deletedAt" is null
1167
+ join "memberOrganizations" mo on m.id = mo."memberId" and mo."organizationId" = :id and mo."dateEnd" is null
1170
1168
group by a."organizationId"),
1171
1169
organization_segments as (select "organizationId", array_agg("segmentId") as "segments"
1172
1170
from "organizationSegments"
0 commit comments