* Checks a single no_activity subscription's watched workflows and fires * events for the inactive ones, accumulating counts into `result`. The * watched-workflow scan is keyset-paginated, so coverage is complete even in * workspaces with more workflows than one page.
( subscription: SimSubscription, result: NoActivityPollResult )
| 206 | * workspaces with more workflows than one page. |
| 207 | */ |
| 208 | async function checkSubscription( |
| 209 | subscription: SimSubscription, |
| 210 | result: NoActivityPollResult |
| 211 | ): Promise<void> { |
| 212 | const config = parseSubscriptionConfig(subscription.webhook.providerConfig) |
| 213 | if (!config || config.eventType !== 'no_activity') return |
| 214 | |
| 215 | const workspaceId = subscription.workflow.workspaceId |
| 216 | if (!workspaceId) return |
| 217 | |
| 218 | let cursor: string | null = null |
| 219 | while (true) { |
| 220 | const page = await fetchWatchedWorkflowPage( |
| 221 | workspaceId, |
| 222 | subscription.webhook.workflowId, |
| 223 | config, |
| 224 | cursor |
| 225 | ) |
| 226 | if (page.length === 0) break |
| 227 | |
| 228 | cursor = page[page.length - 1].id |
| 229 | |
| 230 | for (const sourceWorkflow of page) { |
| 231 | await checkWatchedWorkflow(subscription, config, sourceWorkflow, result) |
| 232 | } |
| 233 | |
| 234 | if (page.length < NO_ACTIVITY_WORKFLOW_PAGE_SIZE) break |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Checks every no_activity subscription and fires side-effect workflows for |
no test coverage detected