diff --git a/apps/dashboard/jobs/utils/generate-cron-tag.ts b/apps/dashboard/jobs/utils/generate-cron-tag.ts new file mode 100644 index 0000000000..ef01e0649b --- /dev/null +++ b/apps/dashboard/jobs/utils/generate-cron-tag.ts @@ -0,0 +1,15 @@ +export function generateCronTag(teamId: string): string { + // Use teamId to generate a deterministic random minute and hour + const hash = Array.from(teamId).reduce( + (acc, char) => acc + char.charCodeAt(0), + 0, + ); + + // Generate minute (0-59) and hour (0-23) based on hash + const minute = hash % 60; + const hour = hash % 24; + + // Return cron expression that runs daily at the generated time + // Format: minute hour * * * + return `${minute} ${hour} * * *`; +} diff --git a/apps/dashboard/src/actions/institutions/reconnect-gocardless-link.tsx b/apps/dashboard/src/actions/institutions/reconnect-gocardless-link.tsx index 7d5bdb2892..58630cc5aa 100644 --- a/apps/dashboard/src/actions/institutions/reconnect-gocardless-link.tsx +++ b/apps/dashboard/src/actions/institutions/reconnect-gocardless-link.tsx @@ -30,12 +30,6 @@ export const reconnectGoCardLessLinkAction = authActionClient }, ctx: { user }, }) => { - await client.institutions[":id"].usage.$put({ - param: { - id: institutionId, - }, - }); - const reference = `${user.team_id}_${nanoid()}`; const link = new URL(redirectTo); diff --git a/apps/dashboard/src/app/api/test/route.ts b/apps/dashboard/src/app/api/test/route.ts deleted file mode 100644 index a06fe0c2f5..0000000000 --- a/apps/dashboard/src/app/api/test/route.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { type NextRequest, NextResponse } from "next/server"; - -const accessToken = ""; - -export async function GET(req: NextRequest) { - const requestUrl = new URL(req.url); - const page = Number(requestUrl.searchParams.get("page") ?? 0); - - const response = await fetch( - `https://bankaccountdata.gocardless.com/api/v2/requisitions?limit=100&offset=${page * 100}`, - { - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }, - ); - - return NextResponse.json(await response.json()); -} diff --git a/apps/engine/src/providers/gocardless/gocardless-api.ts b/apps/engine/src/providers/gocardless/gocardless-api.ts index 253f4bc6cc..9d9fe2cf27 100644 --- a/apps/engine/src/providers/gocardless/gocardless-api.ts +++ b/apps/engine/src/providers/gocardless/gocardless-api.ts @@ -30,8 +30,8 @@ export class GoCardLessApi { #baseUrl = "https://bankaccountdata.gocardless.com"; // Cache keys - #accessTokenCacheKey = "gocardless_access_token_v2"; - #refreshTokenCacheKey = "gocardless_refresh_token_v2"; + #accessTokenCacheKey = "gocardless_access_token"; + #refreshTokenCacheKey = "gocardless_refresh_token"; #institutionsCacheKey = "gocardless_institutions"; #kv: KVNamespace;