Skip to content

Commit 219fd8a

Browse files
committed
fix
1 parent be25958 commit 219fd8a

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

services/apps/cache_worker/src/activities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
checkOrganizationExists,
33
dropOrgIdFromRedis,
4-
getOrgIdsFromRedis,
4+
getOrganizationIdsFromRedis,
55
syncOrganization,
66
} from './activities/computeAggs/organization'
77
import {
@@ -44,7 +44,7 @@ export {
4444
getActivePlatforms,
4545
findNewActivityPlatforms,
4646
updateMemberMergeSuggestionsLastGeneratedAt,
47-
getOrgIdsFromRedis,
47+
getOrganizationIdsFromRedis,
4848
dropOrgIdFromRedis,
4949
checkOrganizationExists,
5050
syncOrganization,

services/apps/cache_worker/src/activities/computeAggs/organization.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ interface IScanResult {
99
totalSize: number
1010
}
1111

12-
export async function getOrgIdsFromRedis(batchSize = 100): Promise<IScanResult> {
13-
let organizationIds: string[] = []
12+
export async function getOrganizationIdsFromRedis(batchSize = 100): Promise<IScanResult> {
1413
try {
1514
const totalSize = await svc.redis.sCard('organizationIdsForAggComputation')
16-
organizationIds = await svc.redis.sendCommand([
15+
const organizationIds = await svc.redis.sendCommand<string[]>([
1716
'SRANDMEMBER',
1817
'organizationIdsForAggComputation',
1918
batchSize.toString(),

services/apps/cache_worker/src/workflows/compute-orgs-agg/getAndComputeOrgAggs.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,15 @@ dailyGetAndComputeOrgAggs is a Temporal workflow that:
2121
cancelled if the parent workflow stops.
2222
*/
2323
export async function dailyGetAndComputeOrgAggs(): Promise<void> {
24-
const testRun = true
25-
const { organizationIds, totalSize } = await activity.getOrgIdsFromRedis()
24+
const { organizationIds, totalSize } = await activity.getOrganizationIdsFromRedis()
2625

27-
console.log('organizationIds', organizationIds)
28-
console.log('totalSize', totalSize)
29-
30-
if (organizationIds.length === 0) {
31-
console.log('No more organizations to process!')
26+
if (!totalSize) {
27+
console.log('No organizations found - finishing workflow!')
3228
return
3329
}
3430

31+
console.log(`Found ${totalSize} organizations for aggs computation!`)
32+
3533
const info = workflowInfo()
3634

3735
await Promise.all(
@@ -52,7 +50,5 @@ export async function dailyGetAndComputeOrgAggs(): Promise<void> {
5250
)
5351

5452
// Continue with the next batch
55-
if (!testRun) {
56-
await continueAsNew<typeof dailyGetAndComputeOrgAggs>()
57-
}
53+
await continueAsNew<typeof dailyGetAndComputeOrgAggs>()
5854
}

0 commit comments

Comments
 (0)