Skip to content

Commit d7f4e8c

Browse files
committed
fix: code review fixed
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent fc137a6 commit d7f4e8c

3 files changed

Lines changed: 34 additions & 39 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ export abstract class TransformerBase {
114114
if (result === null) {
115115
return null
116116
}
117-
return Array.isArray(result) ? result : [result]
117+
const arr = Array.isArray(result) ? result : [result]
118+
return arr.length > 0 ? arr : null
118119
} catch (err) {
119120
const message = err instanceof Error ? err.message : String(err)
120121
const stack = err instanceof Error ? err.stack : undefined

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const buildSourceQuery = (sinceTimestamp?: string): string => {
8686
8787
-- Updated records in existing segments
8888
${select}
89-
AND t.MEETING_DATE > '${sinceTimestamp}'::DATE
89+
AND t.MEETING_DATE >= '${sinceTimestamp}'::DATE
9090
${dedup}
9191
9292
UNION

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

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -71,44 +71,36 @@ export class MeetingAttendanceTransformer extends TransformerBase {
7171
meetingType: (row.RAW_COMMITTEE_TYPE as string | null) || null,
7272
}
7373

74-
const member = {
75-
displayName,
76-
identities,
77-
organizations: this.buildOrganizations(row),
78-
}
79-
80-
const segment = { slug: segmentSlug, sourceId: segmentSourceId }
74+
const organizations = this.buildOrganizations(row)
75+
76+
const buildActivity = (
77+
type: MeetingsActivityType,
78+
sourceIdSuffix: string,
79+
): TransformedActivity => ({
80+
activity: {
81+
type,
82+
platform: PlatformType.MEETINGS,
83+
timestamp,
84+
score: MEETINGS_GRID[type].score,
85+
sourceId: `${primaryKey}_${sourceIdSuffix}`,
86+
member: {
87+
displayName,
88+
identities: [...identities],
89+
organizations: organizations ? [...organizations] : undefined,
90+
},
91+
attributes: { ...attributes },
92+
} as IActivityData,
93+
segment: { slug: segmentSlug, sourceId: segmentSourceId },
94+
})
8195

8296
const activities: TransformedActivity[] = []
8397

8498
if (row.WAS_INVITED === true) {
85-
activities.push({
86-
activity: {
87-
type: MeetingsActivityType.INVITED_MEETING,
88-
platform: PlatformType.MEETINGS,
89-
timestamp,
90-
score: MEETINGS_GRID[MeetingsActivityType.INVITED_MEETING].score,
91-
sourceId: `${primaryKey}_invited`,
92-
member: { ...member },
93-
attributes,
94-
} as IActivityData,
95-
segment,
96-
})
99+
activities.push(buildActivity(MeetingsActivityType.INVITED_MEETING, 'invited'))
97100
}
98101

99102
if (row.INVITEE_ATTENDED === true) {
100-
activities.push({
101-
activity: {
102-
type: MeetingsActivityType.ATTENDED_MEETING,
103-
platform: PlatformType.MEETINGS,
104-
timestamp,
105-
score: MEETINGS_GRID[MeetingsActivityType.ATTENDED_MEETING].score,
106-
sourceId: `${primaryKey}_attended`,
107-
member: { ...member },
108-
attributes,
109-
} as IActivityData,
110-
segment,
111-
})
103+
activities.push(buildActivity(MeetingsActivityType.ATTENDED_MEETING, 'attended'))
112104
}
113105

114106
if (activities.length === 0) {
@@ -121,18 +113,20 @@ export class MeetingAttendanceTransformer extends TransformerBase {
121113
private buildOrganizations(
122114
row: Record<string, unknown>,
123115
): IActivityData['member']['organizations'] {
116+
const website = (row.ORG_WEBSITE as string | null)?.trim() || null
117+
const domainAliases = (row.ORG_DOMAIN_ALIASES as string | null)?.trim() || null
124118
const accountName = (row.ACCOUNT_NAME as string | null)?.trim() || null
125-
if (!accountName) {
119+
120+
if (!accountName && !website && !domainAliases) {
126121
return undefined
127122
}
128123

129-
const website = (row.ORG_WEBSITE as string | null)?.trim() || null
130-
const domainAliases = (row.ORG_DOMAIN_ALIASES as string | null)?.trim() || null
124+
const displayName = accountName || website
131125

132-
if (this.isIndividualNoAccount(accountName)) {
126+
if (this.isIndividualNoAccount(displayName)) {
133127
return [
134128
{
135-
displayName: accountName,
129+
displayName,
136130
source: OrganizationSource.MEETINGS,
137131
identities: website
138132
? [
@@ -175,7 +169,7 @@ export class MeetingAttendanceTransformer extends TransformerBase {
175169

176170
return [
177171
{
178-
displayName: accountName,
172+
displayName,
179173
source: OrganizationSource.MEETINGS,
180174
identities,
181175
logo: (row.LOGO_URL as string | null)?.trim() || undefined,

0 commit comments

Comments
 (0)