Skip to content

Commit

Permalink
Run sync connection for all connections
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 2, 2024
1 parent 93000aa commit dadf3b5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions apps/dashboard/jobs/tasks/bank/scheduler/bank-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { createClient } from "@midday/supabase/job";
import { logger, schedules } from "@trigger.dev/sdk/v3";
import { syncConnection } from "../sync/connection";

// This is a fan-out pattern. We want to trigger a task for each bank connection
// that has a status of "connected".
// This is a fan-out pattern. We want to trigger a job for each bank connection
// Then in sync connection we check if the connection is connected and if not we update the status (Connected, Disconnected)
export const bankSyncScheduler = schedules.task({
id: "bank-sync-scheduler",
maxDuration: 600,
Expand All @@ -20,12 +20,10 @@ export const bankSyncScheduler = schedules.task({
}

try {
// Get all bank connections that has a status of "connected"
const { data: bankConnections } = await supabase
.from("bank_connections")
.select("id")
.eq("team_id", teamId)
.eq("status", "connected")
.throwOnError();

const formattedConnections = bankConnections?.map((connection) => ({
Expand Down

0 comments on commit dadf3b5

Please sign in to comment.