Skip to content

Commit 17d1bfd

Browse files
authored
fix: prevent duplicate merge suggestion workflow runs (CM-1217) (#4173)
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent ef99959 commit 17d1bfd

5 files changed

Lines changed: 22 additions & 116 deletions

File tree

services/apps/merge_suggestions_worker/src/schedules/memberMergeSuggestions.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
import { ScheduleAlreadyRunning, ScheduleOverlapPolicy } from '@temporalio/client'
22

3-
import { IS_DEV_ENV, IS_TEST_ENV } from '@crowd/common'
3+
import { DEFAULT_TENANT_ID } from '@crowd/common'
44

55
import { svc } from '../main'
6-
import { spawnMemberMergeSuggestionsForAllTenants } from '../workflows/spawnMemberMergeSuggestionsForAllTenants'
6+
import { generateMemberMergeSuggestions } from '../workflows/generateMemberMergeSuggestions'
77

88
export const scheduleGenerateMemberMergeSuggestions = async () => {
99
try {
1010
await svc.temporal.schedule.create({
1111
scheduleId: 'member-merge-suggestions',
12-
spec:
13-
IS_DEV_ENV || IS_TEST_ENV
14-
? {
15-
cronExpressions: ['*/2 * * * *'],
16-
}
17-
: {
18-
intervals: [
19-
{
20-
every: '2 hours',
21-
},
22-
],
23-
},
12+
spec: {
13+
cronExpressions: ['0 */2 * * *'],
14+
},
2415
policies: {
2516
overlap: ScheduleOverlapPolicy.BUFFER_ONE,
2617
catchupWindow: '1 minute',
2718
},
2819
action: {
2920
type: 'startWorkflow',
30-
workflowType: spawnMemberMergeSuggestionsForAllTenants,
21+
workflowType: generateMemberMergeSuggestions,
3122
taskQueue: 'merge-suggestions',
32-
workflowExecutionTimeout: '5 minutes',
23+
args: [
24+
{
25+
tenantId: DEFAULT_TENANT_ID,
26+
},
27+
],
3328
},
3429
})
3530
} catch (err) {

services/apps/merge_suggestions_worker/src/schedules/organizationMergeSuggestions.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
import { ScheduleAlreadyRunning, ScheduleOverlapPolicy } from '@temporalio/client'
22

3-
import { IS_DEV_ENV, IS_TEST_ENV } from '@crowd/common'
3+
import { DEFAULT_TENANT_ID } from '@crowd/common'
44

55
import { svc } from '../main'
6-
import { spawnOrganizationMergeSuggestionsForAllTenants } from '../workflows/spawnOrganizationMergeSuggestionsForAllTenants'
6+
import { generateOrganizationMergeSuggestions } from '../workflows/generateOrganizationMergeSuggestions'
77

88
export const scheduleGenerateOrganizationMergeSuggestions = async () => {
99
try {
1010
await svc.temporal.schedule.create({
1111
scheduleId: 'organization-merge-suggestions',
12-
spec:
13-
IS_DEV_ENV || IS_TEST_ENV
14-
? {
15-
cronExpressions: ['*/2 * * * *'],
16-
}
17-
: {
18-
intervals: [
19-
{
20-
every: '2 hours',
21-
},
22-
],
23-
},
12+
spec: {
13+
cronExpressions: ['0 */2 * * *'],
14+
},
2415
policies: {
2516
overlap: ScheduleOverlapPolicy.BUFFER_ONE,
2617
catchupWindow: '1 minute',
2718
},
2819
action: {
2920
type: 'startWorkflow',
30-
workflowType: spawnOrganizationMergeSuggestionsForAllTenants,
21+
workflowType: generateOrganizationMergeSuggestions,
3122
taskQueue: 'merge-suggestions',
32-
workflowExecutionTimeout: '5 minutes',
23+
args: [
24+
{
25+
tenantId: DEFAULT_TENANT_ID,
26+
},
27+
],
3328
},
3429
})
3530
} catch (err) {

services/apps/merge_suggestions_worker/src/workflows.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@ import { generateMemberMergeSuggestions } from './workflows/generateMemberMergeS
22
import { generateOrganizationMergeSuggestions } from './workflows/generateOrganizationMergeSuggestions'
33
import { mergeMembersWithLLM } from './workflows/mergeMembersWithLLM'
44
import { mergeOrganizationsWithLLM } from './workflows/mergeOrganizationsWithLLM'
5-
import { spawnMemberMergeSuggestionsForAllTenants } from './workflows/spawnMemberMergeSuggestionsForAllTenants'
6-
import { spawnOrganizationMergeSuggestionsForAllTenants } from './workflows/spawnOrganizationMergeSuggestionsForAllTenants'
75
import { testMergingEntitiesWithLLM } from './workflows/testMergingEntitiesWithLLM'
86

97
export {
108
generateMemberMergeSuggestions,
11-
spawnMemberMergeSuggestionsForAllTenants,
129
generateOrganizationMergeSuggestions,
13-
spawnOrganizationMergeSuggestionsForAllTenants,
1410
testMergingEntitiesWithLLM,
1511
mergeOrganizationsWithLLM,
1612
mergeMembersWithLLM,

services/apps/merge_suggestions_worker/src/workflows/spawnMemberMergeSuggestionsForAllTenants.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

services/apps/merge_suggestions_worker/src/workflows/spawnOrganizationMergeSuggestionsForAllTenants.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)