Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix data-sink-worker when activity marked deleted #1846

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions services/apps/data_sink_worker/src/repo/activity.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface IDbActivity {
url?: string
sentiment: ISentimentAnalysisResult
organizationId?: string
deletedAt?: string
}

export interface IDbActivityCreateData {
Expand Down
4 changes: 2 additions & 2 deletions services/apps/data_sink_worker/src/repo/activity.repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export default class ActivityRepository extends RepositoryBase<ActivityRepositor
title,
channel,
url,
sentiment
sentiment,
"deletedAt"
from activities
where "tenantId" = $(tenantId)
and "segmentId" = $(segmentId)
and "sourceId" = $(sourceId)
and "deletedAt" is null
`
public async findExisting(
tenantId: string,
Expand Down
13 changes: 12 additions & 1 deletion services/apps/data_sink_worker/src/service/activity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,15 @@ export default class ActivityService extends LoggerBase {
// find existing activity
const dbActivity = await txRepo.findExisting(tenantId, segmentId, activity.sourceId)

if (dbActivity && dbActivity?.deletedAt) {
// we found an existing activity but it's deleted - nothing to do here
this.log.trace(
{ activityId: dbActivity.id },
'Found existing activity but it is deleted, nothing to do here.',
)
return
}

let createActivity = false

if (dbActivity) {
Expand Down Expand Up @@ -846,7 +855,9 @@ export default class ActivityService extends LoggerBase {
}
})

await this.searchSyncWorkerEmitter.triggerMemberSync(tenantId, memberId)
if (memberId) {
await this.searchSyncWorkerEmitter.triggerMemberSync(tenantId, memberId)
}
if (objectMemberId) {
await this.searchSyncWorkerEmitter.triggerMemberSync(tenantId, objectMemberId)
}
Expand Down
Loading