MCPcopy Index your code
hub / github.com/simstudioai/sim / checkConsecutiveFailures

Function checkConsecutiveFailures

apps/sim/lib/workspace-events/rules.ts:24–35  ·  view source on GitHub ↗
(workflowId: string, threshold: number)

Source from the content-addressed store, hash-verified

22}
23
24async 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

Callers 1

evaluateRuleFunction · 0.85

Calls 2

eqFunction · 0.50

Tested by

no test coverage detected