File tree Expand file tree Collapse file tree 3 files changed +10
-15
lines changed
services/apps/cache_worker/src
workflows/compute-orgs-agg Expand file tree Collapse file tree 3 files changed +10
-15
lines changed Original file line number Diff line number Diff line change 11import {
22 checkOrganizationExists ,
33 dropOrgIdFromRedis ,
4- getOrgIdsFromRedis ,
4+ getOrganizationIdsFromRedis ,
55 syncOrganization ,
66} from './activities/computeAggs/organization'
77import {
@@ -44,7 +44,7 @@ export {
4444 getActivePlatforms ,
4545 findNewActivityPlatforms ,
4646 updateMemberMergeSuggestionsLastGeneratedAt ,
47- getOrgIdsFromRedis ,
47+ getOrganizationIdsFromRedis ,
4848 dropOrgIdFromRedis ,
4949 checkOrganizationExists ,
5050 syncOrganization ,
Original file line number Diff line number Diff 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 ( ) ,
Original file line number Diff line number Diff line change @@ -21,17 +21,15 @@ dailyGetAndComputeOrgAggs is a Temporal workflow that:
2121 cancelled if the parent workflow stops.
2222*/
2323export 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}
You can’t perform that action at this time.
0 commit comments