@@ -9,25 +9,26 @@ import {
99 groupBy ,
1010} from '@crowd/common'
1111import { formatSql , getDbInstance , prepareForModification } from '@crowd/database'
12- import { getServiceChildLogger , getServiceLogger } from '@crowd/logging'
12+ import { getServiceLogger } from '@crowd/logging'
1313import { RedisClient } from '@crowd/redis'
1414import {
1515 ALL_PLATFORM_TYPES ,
1616 MemberAttributeType ,
1717 MemberIdentityType ,
1818 PageData ,
19+ SegmentData ,
1920 SegmentType ,
2021} from '@crowd/types'
2122
22- import { findManyLfxMemberships } from '../lfx_memberships'
23+ import { LfxMembership , findManyLfxMemberships } from '../lfx_memberships'
2324import { findMaintainerRoles } from '../maintainers'
2425import {
2526 IDbMemberCreateData ,
2627 IDbMemberUpdateData ,
2728} from '../old/apps/data_sink_worker/repo/member.data'
2829import { OrganizationField , queryOrgs } from '../organizations'
2930import { QueryExecutor } from '../queryExecutor'
30- import { fetchManySegments , findSegmentById } from '../segments'
31+ import { fetchManySegments } from '../segments'
3132import { QueryOptions , QueryResult , queryTable , queryTableById } from '../utils'
3233
3334import { getMemberAttributeSettings } from './attributeSettings'
@@ -36,6 +37,35 @@ import { IDbMemberAttributeSetting, IDbMemberData } from './types'
3637import { fetchManyMemberIdentities , fetchManyMemberOrgs , fetchManyMemberSegments } from '.'
3738
3839const log = getServiceLogger ( )
40+ interface MemberOrganization {
41+ id : string
42+ organizationId : string
43+ dateStart ?: string
44+ dateEnd ?: string
45+ affiliationOverride ?: {
46+ isPrimaryWorkExperience ?: boolean
47+ }
48+ }
49+
50+ interface MemberOrganizationData {
51+ memberId : string
52+ organizations : MemberOrganization [ ]
53+ }
54+
55+ interface OrganizationInfo {
56+ id : string
57+ displayName : string
58+ logo : string
59+ createdAt : string
60+ }
61+
62+ interface MemberSegmentData {
63+ memberId : string
64+ segments : Array < {
65+ segmentId : string
66+ activityCount : number
67+ } >
68+ }
3969
4070export enum MemberField {
4171 ATTRIBUTES = 'attributes' ,
@@ -210,7 +240,10 @@ const buildQuery = (
210240 ` . trim ( )
211241}
212242
213- const sortActiveOrganizations = ( activeOrgs : any [ ] , organizationsInfo : any [ ] ) : any [ ] => {
243+ const sortActiveOrganizations = (
244+ activeOrgs : MemberOrganization [ ] ,
245+ organizationsInfo : OrganizationInfo [ ] ,
246+ ) : MemberOrganization [ ] => {
214247 return activeOrgs . sort ( ( a , b ) => {
215248 if ( ! a || ! b ) return 0
216249
@@ -247,8 +280,8 @@ const sortActiveOrganizations = (activeOrgs: any[], organizationsInfo: any[]): a
247280
248281const fetchOrganizationData = async (
249282 qx : QueryExecutor ,
250- memberOrganizations : any [ ] ,
251- ) : Promise < { orgs : any [ ] ; lfx : any [ ] } > => {
283+ memberOrganizations : MemberOrganizationData [ ] ,
284+ ) : Promise < { orgs : OrganizationInfo [ ] ; lfx : LfxMembership [ ] } > => {
252285 if ( memberOrganizations . length === 0 ) {
253286 return { orgs : [ ] , lfx : [ ] }
254287 }
@@ -280,7 +313,10 @@ const fetchOrganizationData = async (
280313 return { orgs, lfx }
281314}
282315
283- const fetchSegmentData = async ( qx : QueryExecutor , memberSegments : any [ ] ) : Promise < any [ ] > => {
316+ const fetchSegmentData = async (
317+ qx : QueryExecutor ,
318+ memberSegments : MemberSegmentData [ ] ,
319+ ) : Promise < SegmentData [ ] > => {
284320 if ( memberSegments . length === 0 ) {
285321 return [ ]
286322 }
@@ -464,7 +500,7 @@ export async function queryMembersAdvanced(
464500 ] )
465501
466502 if ( include . memberOrganizations ) {
467- const { orgs = [ ] , lfx = [ ] } = orgExtra as { orgs : any [ ] ; lfx : any [ ] }
503+ const { orgs = [ ] , lfx = [ ] } = orgExtra
468504
469505 for ( const member of rows ) {
470506 member . organizations = [ ]
0 commit comments