mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
fix(inactivity-poll): need to respect level and trigger filters (#2431)
This commit is contained in:
committed by
GitHub
parent
3120a785df
commit
1ae3b47f5c
@@ -5,7 +5,7 @@ import {
|
|||||||
workspaceNotificationDelivery,
|
workspaceNotificationDelivery,
|
||||||
workspaceNotificationSubscription,
|
workspaceNotificationSubscription,
|
||||||
} from '@sim/db/schema'
|
} from '@sim/db/schema'
|
||||||
import { and, eq, gte, sql } from 'drizzle-orm'
|
import { and, eq, gte, inArray, sql } from 'drizzle-orm'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags'
|
import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags'
|
||||||
import { createLogger } from '@/lib/logs/console/logger'
|
import { createLogger } from '@/lib/logs/console/logger'
|
||||||
@@ -45,6 +45,8 @@ async function checkWorkflowInactivity(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const windowStart = new Date(Date.now() - (alertConfig.inactivityHours || 24) * 60 * 60 * 1000)
|
const windowStart = new Date(Date.now() - (alertConfig.inactivityHours || 24) * 60 * 60 * 1000)
|
||||||
|
const triggerFilter = subscription.triggerFilter
|
||||||
|
const levelFilter = subscription.levelFilter
|
||||||
|
|
||||||
const recentLogs = await db
|
const recentLogs = await db
|
||||||
.select({ id: workflowExecutionLogs.id })
|
.select({ id: workflowExecutionLogs.id })
|
||||||
@@ -52,7 +54,9 @@ async function checkWorkflowInactivity(
|
|||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(workflowExecutionLogs.workflowId, workflowId),
|
eq(workflowExecutionLogs.workflowId, workflowId),
|
||||||
gte(workflowExecutionLogs.createdAt, windowStart)
|
gte(workflowExecutionLogs.createdAt, windowStart),
|
||||||
|
inArray(workflowExecutionLogs.trigger, triggerFilter),
|
||||||
|
inArray(workflowExecutionLogs.level, levelFilter)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.limit(1)
|
.limit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user