@@ -14,8 +14,6 @@ import {
1414import { EntityType } from '../old/apps/script_executor_worker/types'
1515import { QueryExecutor } from '../queryExecutor'
1616
17- import { EmailDomainMemberOrganizationActivityDate } from './types'
18-
1917/* eslint-disable @typescript-eslint/no-explicit-any */
2018
2119export async function fetchMemberOrganizations (
@@ -61,71 +59,6 @@ export async function fetchMemberOrganizationsBySource(
6159 )
6260}
6361
64- export async function fetchEmailDomainMemberOrganizationsWithoutDates (
65- qx : QueryExecutor ,
66- limit : number ,
67- afterMemberId ?: string ,
68- ) : Promise < string [ ] > {
69- const rows = await qx . select (
70- `
71- SELECT DISTINCT "memberId"
72- FROM "memberOrganizations"
73- WHERE "source" = 'email-domain'
74- AND "dateStart" IS NULL
75- AND "dateEnd" IS NULL
76- AND "deletedAt" IS NULL
77- ${ afterMemberId ? `AND "memberId" > $(afterMemberId)` : '' }
78- ORDER BY "memberId"
79- LIMIT $(limit)
80- ` ,
81- { limit, afterMemberId } ,
82- )
83-
84- return rows . map ( ( r ) => r . memberId )
85- }
86-
87- export async function fetchEmailDomainMemberOrganizationActivityDates (
88- qx : QueryExecutor ,
89- memberId : string ,
90- ) : Promise < EmailDomainMemberOrganizationActivityDate [ ] > {
91- return qx . select (
92- `
93- WITH email_domain_member_orgs AS (
94- SELECT DISTINCT
95- mo."memberId",
96- mo."organizationId",
97- lower(oi.value) AS domain
98- FROM "memberOrganizations" mo
99- INNER JOIN "organizationIdentities" oi
100- ON oi."organizationId" = mo."organizationId"
101- AND oi.type = 'primary-domain'
102- AND oi.verified = true
103- WHERE mo."memberId" = $(memberId)
104- AND mo."source" = 'email-domain'
105- AND mo."deletedAt" IS NULL
106- )
107- SELECT DISTINCT
108- edmo."memberId",
109- edmo."organizationId",
110- ar."timestamp"::date::text AS date
111- FROM email_domain_member_orgs edmo
112- INNER JOIN "memberIdentities" mi
113- ON mi."memberId" = edmo."memberId"
114- AND mi.verified = true
115- AND mi.type = 'email'
116- AND mi."deletedAt" IS NULL
117- AND lower(split_part(mi.value, '@', 2)) = edmo.domain
118- INNER JOIN "activityRelations" ar
119- ON ar."memberId" = mi."memberId"
120- AND ar.platform = mi.platform
121- AND lower(ar.username) = lower(mi.value)
122- AND ar."timestamp" IS NOT NULL
123- ORDER BY edmo."memberId", edmo."organizationId", date
124- ` ,
125- { memberId } ,
126- )
127- }
128-
12962export async function fetchOrganizationMemberIds (
13063 qx : QueryExecutor ,
13164 organizationId : string ,
0 commit comments