|
37 | 37 | * CROWD_TEMPORAL_NAMESPACE - Temporal namespace |
38 | 38 | * SERVICE - Service identifier (used by Temporal client) |
39 | 39 | */ |
| 40 | +import { WorkflowIdReusePolicy } from '@temporalio/client' |
| 41 | + |
40 | 42 | import { DEFAULT_TENANT_ID } from '@crowd/common' |
41 | 43 | import { WRITE_DB_CONFIG, getDbConnection } from '@crowd/data-access-layer/src/database' |
42 | 44 | import { pgpQx } from '@crowd/data-access-layer/src/queryExecutor' |
43 | 45 | import { getServiceChildLogger } from '@crowd/logging' |
44 | 46 | import { TEMPORAL_CONFIG, getTemporalClient } from '@crowd/temporal' |
45 | | -import { WorkflowIdReusePolicy } from '@temporalio/client' |
46 | 47 |
|
47 | 48 | const ENRICHMENT_SOURCES = ['enrichment-progai', 'enrichment-clearbit', 'enrichment-crustdata'] |
48 | 49 |
|
@@ -181,21 +182,24 @@ async function main() { |
181 | 182 | let totalFailed = 0 |
182 | 183 | let totalProcessed = 0 |
183 | 184 |
|
184 | | - while (true) { |
| 185 | + let hasMore = true |
| 186 | + while (hasMore) { |
185 | 187 | pageNum++ |
186 | 188 |
|
187 | 189 | const remaining = opts.limit !== null ? opts.limit - totalProcessed : opts.pageSize |
188 | 190 | if (remaining <= 0) { |
189 | 191 | log.info(`Limit of ${opts.limit} members reached.`) |
190 | | - break |
| 192 | + hasMore = false |
| 193 | + continue |
191 | 194 | } |
192 | 195 |
|
193 | 196 | const fetchSize = Math.min(opts.pageSize, remaining) |
194 | 197 | const membersPage = await fetchPage(qx, cursor, fetchSize) |
195 | 198 |
|
196 | 199 | if (membersPage.length === 0) { |
197 | 200 | log.info('No more members to process.') |
198 | | - break |
| 201 | + hasMore = false |
| 202 | + continue |
199 | 203 | } |
200 | 204 |
|
201 | 205 | const lastMemberId = membersPage[membersPage.length - 1].memberId |
@@ -238,7 +242,7 @@ async function main() { |
238 | 242 |
|
239 | 243 | if (membersPage.length < fetchSize) { |
240 | 244 | // Last page (fewer results than requested means no more data) |
241 | | - break |
| 245 | + hasMore = false |
242 | 246 | } |
243 | 247 |
|
244 | 248 | if (opts.pageDelayMs > 0) { |
|
0 commit comments