|
5 | 5 | workspaceNotificationDelivery, |
6 | 6 | workspaceNotificationSubscription, |
7 | 7 | } from '@sim/db/schema' |
8 | | -import { and, eq, gte, sql } from 'drizzle-orm' |
| 8 | +import { and, eq, gte, inArray, sql } from 'drizzle-orm' |
9 | 9 | import { v4 as uuidv4 } from 'uuid' |
10 | 10 | import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags' |
11 | 11 | import { createLogger } from '@/lib/logs/console/logger' |
@@ -45,14 +45,18 @@ async function checkWorkflowInactivity( |
45 | 45 | } |
46 | 46 |
|
47 | 47 | const windowStart = new Date(Date.now() - (alertConfig.inactivityHours || 24) * 60 * 60 * 1000) |
| 48 | + const triggerFilter = subscription.triggerFilter |
| 49 | + const levelFilter = subscription.levelFilter |
48 | 50 |
|
49 | 51 | const recentLogs = await db |
50 | 52 | .select({ id: workflowExecutionLogs.id }) |
51 | 53 | .from(workflowExecutionLogs) |
52 | 54 | .where( |
53 | 55 | and( |
54 | 56 | eq(workflowExecutionLogs.workflowId, workflowId), |
55 | | - gte(workflowExecutionLogs.createdAt, windowStart) |
| 57 | + gte(workflowExecutionLogs.createdAt, windowStart), |
| 58 | + inArray(workflowExecutionLogs.trigger, triggerFilter), |
| 59 | + inArray(workflowExecutionLogs.level, levelFilter) |
56 | 60 | ) |
57 | 61 | ) |
58 | 62 | .limit(1) |
|
0 commit comments