Skip to content

Commit 67d2672

Browse files
authored
Merge branch 'main' into bugfix/CM-2073
2 parents 6d41508 + c47649d commit 67d2672

File tree

5 files changed

+52
-3
lines changed

5 files changed

+52
-3
lines changed

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/apps/script_executor_worker/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
"@crowd/opensearch": "workspace:*",
2121
"@crowd/redis": "workspace:*",
2222
"@crowd/types": "workspace:*",
23-
"@crowd/common": "workspace:*",
24-
"@crowd/opensearch": "workspace:*",
2523
"@temporalio/workflow": "~1.11.1",
24+
"@temporalio/client": "~1.11.1",
2625
"axios": "^1.6.8",
2726
"moment": "~2.29.4",
2827
"tsx": "^4.7.1",

services/apps/script_executor_worker/src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Config } from '@crowd/archetype-standard'
22
import { Options, ServiceWorker } from '@crowd/archetype-worker'
33

4+
import { schedulePopulateActivityRelations } from './schedules/schedulePopulateActivityRelations'
5+
46
const config: Config = {
57
envvars: ['CROWD_API_SERVICE_URL', 'CROWD_API_SERVICE_USER_TOKEN'],
68
producer: {
@@ -33,5 +35,8 @@ export const svc = new ServiceWorker(config, options)
3335

3436
setImmediate(async () => {
3537
await svc.init()
38+
39+
await schedulePopulateActivityRelations()
40+
3641
await svc.start()
3742
})
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { ScheduleAlreadyRunning, ScheduleOverlapPolicy } from '@temporalio/client'
2+
3+
import { svc } from '../main'
4+
import { populateActivityRelations } from '../workflows'
5+
6+
export const schedulePopulateActivityRelations = async () => {
7+
try {
8+
await svc.temporal.schedule.create({
9+
scheduleId: 'populateActivityRelations',
10+
spec: {
11+
cronExpressions: ['30 0 * * *'],
12+
},
13+
policies: {
14+
overlap: ScheduleOverlapPolicy.BUFFER_ONE,
15+
catchupWindow: '1 minute',
16+
},
17+
action: {
18+
type: 'startWorkflow',
19+
workflowType: populateActivityRelations,
20+
taskQueue: 'script-executor',
21+
retry: {
22+
initialInterval: '15 seconds',
23+
backoffCoefficient: 2,
24+
maximumAttempts: 3,
25+
},
26+
args: [
27+
{
28+
batchSizePerRun: 10000,
29+
deleteIndexedEntities: false,
30+
},
31+
],
32+
},
33+
})
34+
} catch (err) {
35+
if (err instanceof ScheduleAlreadyRunning) {
36+
svc.log.info('Schedule already registered in Temporal.')
37+
svc.log.info('Configuration may have changed since. Please make sure they are in sync.')
38+
} else {
39+
throw new Error(err)
40+
}
41+
}
42+
}

services/libs/data-access-layer/src/activities/sql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,7 @@ export async function createOrUpdateRelations(
16321632
now(),
16331633
now()
16341634
)
1635-
ON CONFLICT ("activityId", "memberId")
1635+
ON CONFLICT ("activityId")
16361636
DO UPDATE
16371637
SET
16381638
"updatedAt" = EXCLUDED."updatedAt",

0 commit comments

Comments
 (0)