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

Function hasRecentActivity

apps/sim/lib/workspace-events/no-activity.ts:117–136  ·  view source on GitHub ↗

True when the workflow had at least one qualifying execution inside the window.

(
  workflowId: string,
  config: SimSubscriptionConfig
)

Source from the content-addressed store, hash-verified

115
116/** True when the workflow had at least one qualifying execution inside the window. */
117async function hasRecentActivity(
118 workflowId: string,
119 config: SimSubscriptionConfig
120): Promise<boolean> {
121 const windowStart = new Date(Date.now() - config.inactivityHours * 60 * 60 * 1000)
122
123 const recentLogs = await db
124 .select({ id: workflowExecutionLogs.id })
125 .from(workflowExecutionLogs)
126 .where(
127 and(
128 eq(workflowExecutionLogs.workflowId, workflowId),
129 gte(workflowExecutionLogs.startedAt, windowStart),
130 excludeSimExecutionsCondition()
131 )
132 )
133 .limit(1)
134
135 return recentLogs.length > 0
136}
137
138/**
139 * Cooldown for no_activity firings. At least the inactivity window itself —

Callers 1

checkWatchedWorkflowFunction · 0.85

Calls 2

eqFunction · 0.50

Tested by

no test coverage detected