Skip to content

Commit

Permalink
fix: don't prod check paused connectors (#4582)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
2 people authored and flvndvd committed May 26, 2024
1 parent 0f67914 commit 5074184
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ConnectorProvider } from "@dust-tt/types";
import {
makeConfluenceSyncWorkflowId,
type ConnectorProvider,
getIntercomSyncWorkflowId,
makeConfluenceSyncWorkflowId,
} from "@dust-tt/types";
import type { Client, WorkflowHandle } from "@temporalio/client";
import { QueryTypes } from "sequelize";
Expand All @@ -14,6 +14,7 @@ interface ConnectorBlob {
id: number;
dataSourceName: string;
workspaceId: string;
pausedAt: Date | null;
}

interface ProviderCheck {
Expand All @@ -35,7 +36,7 @@ const providersToCheck: Partial<Record<ConnectorProvider, ProviderCheck>> = {

async function listAllConnectorsForProvider(provider: ConnectorProvider) {
const connectors: ConnectorBlob[] = await connectorsReplica.query(
`SELECT id, "dataSourceName", "workspaceId" FROM connectors WHERE "type" = :provider and "errorType" IS NULL`,
`SELECT id, "dataSourceName", "workspaceId", "pausedAt" FROM connectors WHERE "type" = :provider and "errorType" IS NULL`,
{
type: QueryTypes.SELECT,
replacements: {
Expand Down Expand Up @@ -83,6 +84,9 @@ export const checkActiveWorkflows: CheckFunction = async (

const missingActiveWorkflows: any[] = [];
for (const connector of connectors) {
if (connector.pausedAt) {
continue;
}
heartbeat();

const isActive = await areTemporalWorkflowsRunning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ interface NotionConnector {
id: number;
dataSourceName: string;
workspaceId: string;
pausedAt: Date | null;
}

async function listAllNotionConnectors() {
const connectorsReplica = getConnectorReplicaDbConnection();

const notionConnectors: NotionConnector[] = await connectorsReplica.query(
`SELECT id, "dataSourceName", "workspaceId" FROM connectors WHERE "type" = 'notion' and "errorType" IS NULL`,
`SELECT id, "dataSourceName", "workspaceId", "pausedAt" FROM connectors WHERE "type" = 'notion' and "errorType" IS NULL`,
{
type: QueryTypes.SELECT,
}
Expand Down Expand Up @@ -63,6 +64,9 @@ export const checkNotionActiveWorkflows: CheckFunction = async (

const missingActiveWorkflows: any[] = [];
for (const notionConnector of notionConnectors) {
if (notionConnector.pausedAt) {
continue;
}
heartbeat();

const isActive = await areTemporalWorkflowsRunning(client, notionConnector);
Expand Down

0 comments on commit 5074184

Please sign in to comment.