@@ -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