Skip to content

Commit

Permalink
Revalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Nov 13, 2023
1 parent 48299ce commit 0896b16
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 0 additions & 5 deletions apps/dashboard/src/app/api/revalidate/route.ts

This file was deleted.

16 changes: 13 additions & 3 deletions apps/dashboard/src/jobs/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Database } from "@midday/supabase/src/types";
import { eventTrigger } from "@trigger.dev/sdk";
import { Supabase, SupabaseManagement } from "@trigger.dev/supabase";
import { capitalCase } from "change-case";
import { revalidateTag } from "next/cache";
import { z } from "zod";

const mapTransactionMethod = (method: string) => {
Expand Down Expand Up @@ -61,7 +62,6 @@ client.defineJob({
id: "bank-account-created",
name: "Bank Account Created",
version: "1.0.0",
enabled: false,
trigger: supabaseTriggers.onInserted({
table: "bank_accounts",
}),
Expand Down Expand Up @@ -92,7 +92,6 @@ client.defineJob({
name: "Transactions - Latest Transactions",
version: "1.0.0",
trigger: dynamicSchedule,
enabled: false,
integrations: { supabase },
run: async (_, io, ctx) => {
const { data } = await io.supabase.client
Expand Down Expand Up @@ -127,6 +126,12 @@ client.defineJob({
)
.select();

if (transactionsData?.length && transactionsData.length > 0) {
revalidateTag(`transactions_${data?.team_id}`);
revalidateTag(`spending_${data?.team_id}`);
revalidateTag(`metrics_${data?.team_id}`);
}

if (error) {
await io.logger.error(JSON.stringify(error, null, 2));
}
Expand All @@ -139,7 +144,6 @@ client.defineJob({
id: "transactions-initial-sync",
name: "Transactions - Initial",
version: "1.0.0",
enabled: false,
trigger: eventTrigger({
name: "transactions.initial.sync",
schema: z.object({
Expand Down Expand Up @@ -168,6 +172,12 @@ client.defineJob({
)
.select();

if (transactionsData?.length && transactionsData.length > 0) {
revalidateTag(`transactions_${teamId}`);
revalidateTag(`spending_${teamId}`);
revalidateTag(`metrics_${teamId}`);
}

if (error) {
await io.logger.error(JSON.stringify(error, null, 2));
}
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/src/styles/globals.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
html,
body {
height: 100%;
overscroll-behavior: none;
}

*:focus {
Expand Down

0 comments on commit 0896b16

Please sign in to comment.