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

Function fetchWatchedWorkflowPage

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

* Fetches one page of the workflows a no_activity subscription watches: * deployed, active workflows in the subscriber's workspace, minus the * subscriber itself, narrowed to the explicit selection when one is set * (empty selection watches everything). Deployed-only keeps never-runnable * draft

(
  workspaceId: string,
  subscriberWorkflowId: string,
  config: SimSubscriptionConfig,
  afterWorkflowId: string | null
)

Source from the content-addressed store, hash-verified

84 * coverage past a cap.
85 */
86async function fetchWatchedWorkflowPage(
87 workspaceId: string,
88 subscriberWorkflowId: string,
89 config: SimSubscriptionConfig,
90 afterWorkflowId: string | null
91): Promise<Array<{ id: string; name: string }>> {
92 // Subscriber exclusion and the explicit selection must be SQL conditions:
93 // filtering in memory after the LIMIT could drop an explicitly watched
94 // workflow. The ORDER BY drives the keyset cursor.
95 const conditions = [
96 eq(workflow.workspaceId, workspaceId),
97 eq(workflow.isDeployed, true),
98 isNull(workflow.archivedAt),
99 ne(workflow.id, subscriberWorkflowId),
100 ]
101 if (config.workflowIds.length > 0) {
102 conditions.push(inArray(workflow.id, config.workflowIds))
103 }
104 if (afterWorkflowId !== null) {
105 conditions.push(gt(workflow.id, afterWorkflowId))
106 }
107
108 return dbReplica
109 .select({ id: workflow.id, name: workflow.name })
110 .from(workflow)
111 .where(and(...conditions))
112 .orderBy(asc(workflow.id))
113 .limit(NO_ACTIVITY_WORKFLOW_PAGE_SIZE)
114}
115
116/** True when the workflow had at least one qualifying execution inside the window. */
117async function hasRecentActivity(

Callers 1

checkSubscriptionFunction · 0.85

Calls 2

eqFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected