Skip to content

Commit 481bb63

Browse files
authored
fix: prevent individual account org frequent updates [CM-1069] (#3954)
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent 6f9e65a commit 481bb63

3 files changed

Lines changed: 54 additions & 4 deletions

File tree

services/apps/snowflake_connectors/src/core/transformerBase.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ export abstract class TransformerBase {
2929
*/
3030
abstract transformRow(row: Record<string, unknown>): TransformedActivity | null
3131

32+
private static readonly INDIVIDUAL_NO_ACCOUNT_RE = /^individual\s*(?:[-?]|with)\s*no\s+account$/i
33+
34+
protected isIndividualNoAccount(displayName: string | null): boolean {
35+
if (!displayName) {
36+
return false
37+
}
38+
return TransformerBase.INDIVIDUAL_NO_ACCOUNT_RE.test(displayName.trim())
39+
}
40+
3241
/**
3342
* Safe wrapper around transformRow that catches errors and returns null.
3443
*/

services/apps/snowflake_connectors/src/integrations/cvent/event-registrations/transformer.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,29 @@ export class CventTransformer extends TransformerBase {
154154
return undefined
155155
}
156156

157-
const identities: IOrganizationIdentity[] = []
158-
159157
const accountName = (row.ACCOUNT_NAME as string | null)?.trim() || null
158+
const displayName = accountName || website
159+
160+
if (this.isIndividualNoAccount(displayName)) {
161+
return [
162+
{
163+
displayName,
164+
source: OrganizationSource.CVENT,
165+
identities: website
166+
? [
167+
{
168+
platform: PlatformType.CVENT,
169+
value: website,
170+
type: OrganizationIdentityType.PRIMARY_DOMAIN,
171+
verified: true,
172+
},
173+
]
174+
: [],
175+
},
176+
]
177+
}
178+
179+
const identities: IOrganizationIdentity[] = []
160180

161181
if (website) {
162182
identities.push({
@@ -183,7 +203,7 @@ export class CventTransformer extends TransformerBase {
183203

184204
return [
185205
{
186-
displayName: accountName || website,
206+
displayName,
187207
source: OrganizationSource.CVENT,
188208
identities,
189209
logo: (row.LOGO_URL as string | null)?.trim() || undefined,

services/apps/snowflake_connectors/src/integrations/tnc/tncTransformerBase.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ export abstract class TncTransformerBase extends TransformerBase {
2121
return undefined
2222
}
2323

24+
const displayName = (row.ORGANIZATION_NAME as string | null)?.trim() || website
25+
26+
if (this.isIndividualNoAccount(displayName)) {
27+
return [
28+
{
29+
displayName,
30+
source: OrganizationSource.TNC,
31+
identities: website
32+
? [
33+
{
34+
platform: PlatformType.TNC,
35+
value: website,
36+
type: OrganizationIdentityType.PRIMARY_DOMAIN,
37+
verified: true,
38+
},
39+
]
40+
: [],
41+
},
42+
]
43+
}
44+
2445
const identities: IOrganizationIdentity[] = []
2546

2647
if (website) {
@@ -48,7 +69,7 @@ export abstract class TncTransformerBase extends TransformerBase {
4869

4970
return [
5071
{
51-
displayName: (row.ORGANIZATION_NAME as string | null)?.trim() || website,
72+
displayName,
5273
source: OrganizationSource.TNC,
5374
identities,
5475
logo: (row.LOGO_URL as string | null)?.trim() || undefined,

0 commit comments

Comments
 (0)