()
| 247 | * never executed fires once, then respects the cooldown. |
| 248 | */ |
| 249 | export async function pollNoActivityEvents(): Promise<NoActivityPollResult> { |
| 250 | const result: NoActivityPollResult = { subscriptions: 0, checked: 0, fired: 0, skipped: 0 } |
| 251 | |
| 252 | let cursor: string | null = null |
| 253 | while (true) { |
| 254 | const page = await fetchNoActivitySubscriptionPage(cursor) |
| 255 | if (page.length === 0) break |
| 256 | |
| 257 | result.subscriptions += page.length |
| 258 | cursor = page[page.length - 1].webhook.id |
| 259 | |
| 260 | for (const subscription of page) { |
| 261 | await checkSubscription(subscription, result) |
| 262 | } |
| 263 | |
| 264 | if (page.length < NO_ACTIVITY_SUBSCRIPTION_PAGE_SIZE) break |
| 265 | } |
| 266 | |
| 267 | if (result.subscriptions === 0) return result |
| 268 | |
| 269 | logger.info( |
| 270 | `no_activity poll completed: ${result.fired} fired, ${result.skipped} skipped of ${result.checked} checked` |
| 271 | ) |
| 272 | |
| 273 | return result |
| 274 | } |
no test coverage detected