Skip to content

Commit 1ae3b47

Browse files
fix(inactivity-poll): need to respect level and trigger filters (#2431)
1 parent 3120a78 commit 1ae3b47

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apps/sim/lib/notifications/inactivity-polling.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
workspaceNotificationDelivery,
66
workspaceNotificationSubscription,
77
} from '@sim/db/schema'
8-
import { and, eq, gte, sql } from 'drizzle-orm'
8+
import { and, eq, gte, inArray, sql } from 'drizzle-orm'
99
import { v4 as uuidv4 } from 'uuid'
1010
import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags'
1111
import { createLogger } from '@/lib/logs/console/logger'
@@ -45,14 +45,18 @@ async function checkWorkflowInactivity(
4545
}
4646

4747
const windowStart = new Date(Date.now() - (alertConfig.inactivityHours || 24) * 60 * 60 * 1000)
48+
const triggerFilter = subscription.triggerFilter
49+
const levelFilter = subscription.levelFilter
4850

4951
const recentLogs = await db
5052
.select({ id: workflowExecutionLogs.id })
5153
.from(workflowExecutionLogs)
5254
.where(
5355
and(
5456
eq(workflowExecutionLogs.workflowId, workflowId),
55-
gte(workflowExecutionLogs.createdAt, windowStart)
57+
gte(workflowExecutionLogs.createdAt, windowStart),
58+
inArray(workflowExecutionLogs.trigger, triggerFilter),
59+
inArray(workflowExecutionLogs.level, levelFilter)
5660
)
5761
)
5862
.limit(1)

0 commit comments

Comments
 (0)