True when the workflow had at least one qualifying execution inside the window.
( workflowId: string, config: SimSubscriptionConfig )
| 115 | |
| 116 | /** True when the workflow had at least one qualifying execution inside the window. */ |
| 117 | async 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 — |
no test coverage detected