(namespace?: string)
| 34 | } |
| 35 | |
| 36 | async function countAll(namespace?: string): Promise<number> { |
| 37 | let last = 0; |
| 38 | let n = 0; |
| 39 | while (true) { |
| 40 | const batch = await Tasks.getMany({ |
| 41 | namespace: namespace, afterId: last |
| 42 | }); |
| 43 | if (batch && batch.length > 0) { |
| 44 | last = batch[batch.length - 1].id; |
| 45 | n += batch.length; |
| 46 | } else { |
| 47 | break; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | return n |
| 52 | } |
| 53 | |
| 54 | runOnce(script.name, async () => { |
| 55 | await testGetKey(); |