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

Function checkErrorCount

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

Source from the content-addressed store, hash-verified

108}
109
110async function checkErrorCount(
111 workflowId: string,
112 threshold: number,
113 windowHours: number
114): Promise<boolean> {
115 const windowStart = new Date(Date.now() - windowHours * 60 * 60 * 1000)
116
117 const result = await db
118 .select({ count: count() })
119 .from(workflowExecutionLogs)
120 .where(
121 and(
122 eq(workflowExecutionLogs.workflowId, workflowId),
123 eq(workflowExecutionLogs.level, 'error'),
124 gte(workflowExecutionLogs.startedAt, windowStart),
125 excludeSimExecutionsCondition()
126 )
127 )
128
129 const errorCount = result[0]?.count || 0
130 return errorCount >= threshold
131}
132
133/**
134 * Evaluates a rule-based event type against a completed execution.

Callers 1

evaluateRuleFunction · 0.85

Calls 2

eqFunction · 0.50

Tested by

no test coverage detected