Skip to content

Commit d07c84e

Browse files
authored
Revert "chore: backfill email-domain member organization dates (CM-1107)" (#4063)
1 parent ade866b commit d07c84e

5 files changed

Lines changed: 4 additions & 232 deletions

File tree

backend/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
"script:refreshGithubRepoSettings": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/refresh-github-repo-settings.ts",
3333
"script:fix-duplicate-members": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/fix-duplicate-members.ts",
3434
"script:fix-members-activities-after-unaffilation": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/fix-members-activities-after-unaffilation.ts",
35-
"script:process-bot-members": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/process-bot-members.ts",
36-
"script:backfill-email-domain-member-organization-dates": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/backfill-email-domain-member-organization-dates.ts"
35+
"script:process-bot-members": "SERVICE=script TS_NODE_TRANSPILE_ONLY=true tsx src/bin/scripts/process-bot-members.ts"
3736
},
3837
"lint-staged": {
3938
"**/*.ts": [

backend/src/bin/scripts/backfill-email-domain-member-organization-dates.ts

Lines changed: 0 additions & 156 deletions
This file was deleted.

services/apps/script_executor_worker/src/activities/block-project-organization-affiliations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export async function blockMemberOrganizationAffiliation(
5858

5959
export async function markMemberForAffiliationRecalc(memberIds: string[]): Promise<void> {
6060
try {
61-
await svc.redis.sAdd('recalculate-member-affiliations', memberIds)
61+
await svc.redis.sAdd('queue:recalculate:members:affiliation', memberIds)
6262
} catch (error) {
6363
svc.log.error(error, 'Error marking member for affiliation recalc!')
6464
throw error
@@ -67,7 +67,7 @@ export async function markMemberForAffiliationRecalc(memberIds: string[]): Promi
6767

6868
export async function getMembersForAffiliationRecalc(batchSize: number): Promise<string[]> {
6969
try {
70-
return svc.redis.sPop('recalculate-member-affiliations', batchSize)
70+
return svc.redis.sPop('queue:recalculate:members:affiliation', batchSize)
7171
} catch (error) {
7272
svc.log.error(error, 'Error getting members for affiliation recalc!')
7373
throw error

services/libs/data-access-layer/src/members/organizations.ts

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import {
1414
import { EntityType } from '../old/apps/script_executor_worker/types'
1515
import { QueryExecutor } from '../queryExecutor'
1616

17-
import { EmailDomainMemberOrganizationActivityDate } from './types'
18-
1917
/* eslint-disable @typescript-eslint/no-explicit-any */
2018

2119
export 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-
12962
export async function fetchOrganizationMemberIds(
13063
qx: QueryExecutor,
13164
organizationId: string,

services/libs/data-access-layer/src/members/types.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IAttributes, IMemberAttribute, MemberAttributeType, MemberOrgDate } from '@crowd/types'
1+
import { IAttributes, IMemberAttribute, MemberAttributeType } from '@crowd/types'
22

33
export interface IQueryNumberOfNewMembers {
44
segmentIds?: string[]
@@ -93,7 +93,3 @@ export interface IDbMemberBotSuggestionBySegment {
9393
avatarUrl: string
9494
attributes: IAttributes
9595
}
96-
97-
export interface EmailDomainMemberOrganizationActivityDate extends MemberOrgDate {
98-
memberId: string
99-
}

0 commit comments

Comments
 (0)