(workflowId: string, threshold: number)
| 22 | } |
| 23 | |
| 24 | async function checkConsecutiveFailures(workflowId: string, threshold: number): Promise<boolean> { |
| 25 | const recentLogs = await db |
| 26 | .select({ level: workflowExecutionLogs.level }) |
| 27 | .from(workflowExecutionLogs) |
| 28 | .where(and(eq(workflowExecutionLogs.workflowId, workflowId), excludeSimExecutionsCondition())) |
| 29 | .orderBy(desc(workflowExecutionLogs.startedAt)) |
| 30 | .limit(threshold) |
| 31 | |
| 32 | if (recentLogs.length < threshold) return false |
| 33 | |
| 34 | return recentLogs.every((log) => log.level === 'error') |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Fires when the in-window failure rate meets the threshold with at least |
no test coverage detected