Skip to content

Commit 6039d06

Browse files
committed
fix: missing org data
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent f2bf2c8 commit 6039d06

2 files changed

Lines changed: 82 additions & 7 deletions

File tree

services/apps/snowflake_connectors/src/integrations/meetings/meeting-attendance/buildSourceQuery.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ const CDP_MATCHED_SEGMENTS = `
1111
AND s.SOURCE_ID IS NOT NULL
1212
)`
1313

14+
const ORG_ACCOUNTS = `
15+
org_accounts AS (
16+
SELECT account_id, account_name, website, domain_aliases, LOGO_URL, INDUSTRY, N_EMPLOYEES
17+
FROM analytics.bronze_fivetran_salesforce.accounts
18+
WHERE website IS NOT NULL
19+
UNION ALL
20+
SELECT account_id, account_name, website, domain_aliases, NULL AS LOGO_URL, NULL AS INDUSTRY, NULL AS N_EMPLOYEES
21+
FROM analytics.bronze_fivetran_salesforce_b2b.accounts
22+
WHERE website IS NOT NULL
23+
)`
24+
1425
export const buildSourceQuery = (sinceTimestamp?: string): string => {
1526
let select = `
1627
SELECT
@@ -30,29 +41,38 @@ export const buildSourceQuery = (sinceTimestamp?: string): string => {
3041
t.INVITEE_EMAIL,
3142
t.INVITEE_ATTENDED,
3243
t.WAS_INVITED,
33-
t.RAW_COMMITTEE_TYPE
44+
t.RAW_COMMITTEE_TYPE,
45+
org.website AS ORG_WEBSITE,
46+
org.domain_aliases AS ORG_DOMAIN_ALIASES,
47+
org.logo_url AS LOGO_URL,
48+
org.industry AS ORGANIZATION_INDUSTRY,
49+
CAST(org.n_employees AS VARCHAR) AS ORGANIZATION_SIZE
3450
FROM ANALYTICS.SILVER_FACT.MEETING_ATTENDANCE t
3551
INNER JOIN cdp_matched_segments cms
3652
ON cms.slug = t.PROJECT_SLUG
3753
AND cms.sourceId = t.PROJECT_ID
54+
LEFT JOIN org_accounts org
55+
ON t.ACCOUNT_ID = org.account_id
3856
WHERE (t.WAS_INVITED = TRUE OR t.INVITEE_ATTENDED = TRUE)`
3957

4058
if (!IS_PROD_ENV) {
4159
select += ` AND t.PROJECT_SLUG = 'cncf'`
4260
}
4361

4462
const dedup = `
45-
QUALIFY ROW_NUMBER() OVER (PARTITION BY t.PRIMARY_KEY ORDER BY t.MEETING_DATE DESC) = 1`
63+
QUALIFY ROW_NUMBER() OVER (PARTITION BY t.PRIMARY_KEY ORDER BY org.website DESC) = 1`
4664

4765
if (!sinceTimestamp) {
4866
return `
49-
WITH ${CDP_MATCHED_SEGMENTS}
67+
WITH ${ORG_ACCOUNTS},
68+
${CDP_MATCHED_SEGMENTS}
5069
${select}
5170
${dedup}`.trim()
5271
}
5372

5473
return `
55-
WITH ${CDP_MATCHED_SEGMENTS},
74+
WITH ${ORG_ACCOUNTS},
75+
${CDP_MATCHED_SEGMENTS},
5676
new_cdp_segments AS (
5777
SELECT DISTINCT
5878
s.SOURCE_ID AS sourceId,

services/apps/snowflake_connectors/src/integrations/meetings/meeting-attendance/transformer.ts

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { MEETINGS_GRID, MeetingsActivityType } from '@crowd/integrations'
22
import { getServiceChildLogger } from '@crowd/logging'
3-
import { IActivityData, OrganizationSource, PlatformType } from '@crowd/types'
3+
import {
4+
IActivityData,
5+
IOrganizationIdentity,
6+
OrganizationIdentityType,
7+
OrganizationSource,
8+
PlatformType,
9+
} from '@crowd/types'
410

511
import { TransformedActivity, TransformerBase } from '../../../core/transformerBase'
612

@@ -106,15 +112,64 @@ export class MeetingAttendanceTransformer extends TransformerBase {
106112
return undefined
107113
}
108114

115+
const website = (row.ORG_WEBSITE as string | null)?.trim() || null
116+
const domainAliases = (row.ORG_DOMAIN_ALIASES as string | null)?.trim() || null
117+
109118
if (this.isIndividualNoAccount(accountName)) {
110-
return undefined
119+
return [
120+
{
121+
displayName: accountName,
122+
source: OrganizationSource.MEETINGS,
123+
identities: website
124+
? [
125+
{
126+
platform: this.platform,
127+
value: website,
128+
type: OrganizationIdentityType.PRIMARY_DOMAIN,
129+
verified: true,
130+
},
131+
]
132+
: [],
133+
},
134+
]
135+
}
136+
137+
const identities: IOrganizationIdentity[] = []
138+
139+
if (website) {
140+
identities.push({
141+
platform: this.platform,
142+
value: website,
143+
type: OrganizationIdentityType.PRIMARY_DOMAIN,
144+
verified: true,
145+
})
146+
}
147+
148+
if (domainAliases) {
149+
for (const alias of domainAliases.split(',')) {
150+
const trimmed = alias.trim()
151+
if (trimmed) {
152+
identities.push({
153+
platform: this.platform,
154+
value: trimmed,
155+
type: OrganizationIdentityType.ALTERNATIVE_DOMAIN,
156+
verified: true,
157+
})
158+
}
159+
}
111160
}
112161

113162
return [
114163
{
115164
displayName: accountName,
116165
source: OrganizationSource.MEETINGS,
117-
identities: [],
166+
identities,
167+
logo: (row.LOGO_URL as string | null)?.trim() || undefined,
168+
size:
169+
typeof row.ORGANIZATION_SIZE === 'string'
170+
? row.ORGANIZATION_SIZE.trim() || undefined
171+
: undefined,
172+
industry: (row.ORGANIZATION_INDUSTRY as string | null)?.trim() || undefined,
118173
},
119174
]
120175
}

0 commit comments

Comments
 (0)