Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
MEMBER_ORG_STINT_CHANGES_DATES_PREFIX,
MEMBER_ORG_STINT_CHANGES_QUEUE,
inferMemberOrganizationStintChanges,
signalMemberUpdate,
} from '@crowd/common_services'
import {
QueryExecutor,
Expand All @@ -18,6 +19,7 @@ import { WRITE_DB_CONFIG, getDbConnection } from '@crowd/data-access-layer/src/d
import { deleteMemberSegmentAffiliations } from '@crowd/data-access-layer/src/member_segment_affiliations'
import { pgpQx } from '@crowd/data-access-layer/src/queryExecutor'
import { REDIS_CONFIG, RedisCache, getRedisClient } from '@crowd/redis'
import { TEMPORAL_CONFIG, getTemporalClient } from '@crowd/temporal'
import { MemberOrgDate, MemberOrgStintChange, OrganizationSource } from '@crowd/types'

import { IJobDefinition } from '../types'
Expand All @@ -28,15 +30,18 @@ const job: IJobDefinition = {
timeout: 10 * 60,
process: async (ctx) => {
const redis = await getRedisClient(REDIS_CONFIG())
const db = await getDbConnection(WRITE_DB_CONFIG())
const qx = pgpQx(db)

Comment thread
skwowet marked this conversation as resolved.
ctx.log.info('Starting member organization stint inference job.')

const memberIds = await redis.sRandMemberCount(MEMBER_ORG_STINT_CHANGES_QUEUE, 500)

if (!memberIds?.length) return

ctx.log.info({ count: memberIds.length }, 'Processing members from queue.')
const db = await getDbConnection(WRITE_DB_CONFIG())
const qx = pgpQx(db)
const temporal = await getTemporalClient(TEMPORAL_CONFIG())

ctx.log.info({ count: memberIds.length }, 'Processing members from buffer.')
Comment thread
Copilot marked this conversation as resolved.
Outdated

let processed = 0

Expand Down Expand Up @@ -64,6 +69,12 @@ const job: IJobDefinition = {
if (changes.length > 0) {
ctx.log.debug({ memberId, changes }, 'Stint changes identified.')
await qx.tx((tx) => applyStintChanges(tx, changes))

ctx.log.debug(
{ memberId },
'Triggering member update workflow to refresh affiliations.',
)
await signalMemberUpdate(temporal, memberId)
}
Comment on lines 69 to 78
}

Expand Down
Loading