Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Nov 26, 2023
1 parent 7ece4fa commit 6587a38
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 114 deletions.
3 changes: 0 additions & 3 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ GOCARDLESS_SECRET_KEY=
KV_REST_API_URL=
KV_REST_API_TOKEN=
NOVU_API_KEY=
VERCEL_WEBHOOK_SECRET=
PLAID_CLIENT_ID=
PLAID_CLIENT_SECRET=
3 changes: 1 addition & 2 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@hookform/resolvers": "^3.3.2",
"@midday/gocardless": "workspace:*",
"@midday/kv": "workspace:*",
"@midday/plaid": "workspace:*",
"@midday/location": "workspace:*",
"@midday/notification": "workspace:*",
"@midday/supabase": "workspace:*",
Expand Down Expand Up @@ -46,7 +45,7 @@
"devDependencies": {
"@midday/tsconfig": "workspace:*",
"@t3-oss/env-nextjs": "^0.7.1",
"@types/node": "^20.9.5",
"@types/node": "^20.10.0",
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.17",
"typescript": "^5.3.2"
Expand Down
10 changes: 0 additions & 10 deletions apps/dashboard/src/components/charts/transactions-list.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { formatAmount } from "@/utils/format";
import { getTransactions } from "@midday/supabase/cached-queries";
import { Avatar, AvatarFallback, AvatarImage } from "@midday/ui/avatar";
import { Icons } from "@midday/ui/icons";
import { Skeleton } from "@midday/ui/skeleton";
import { cn } from "@midday/ui/utils";
Expand Down Expand Up @@ -60,15 +59,6 @@ export async function TransactionsList({ type, disabled }) {
className="flex p-3"
>
<div className="w-[50%] flex space-x-2">
<Avatar className="rounded-full w-5 h-5">
<AvatarImage src={transaction?.enrichment?.logo_url} />
<AvatarFallback>
<span className="text-[10px]">
{transaction?.name?.charAt(0)}
</span>
</AvatarFallback>
</Avatar>

<span
className={cn(
"text-sm",
Expand Down
91 changes: 45 additions & 46 deletions apps/dashboard/src/jobs/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,52 +334,51 @@ client.defineJob({
run: async (payload, io) => {
const { teamId } = payload;

// const { data: transactionsData } = await io.supabase.client
// .from("transactions")
// .select("id, name")
// .eq("team_id", teamId)
// .is("category", null)
// .is("logo_url", null)
// .is("enrichment_id", null)
// .select();

// async function enrichTransactions(transaction) {
// const { data } = await io.supabase.client
// .rpc("search_enriched_transactions", { term: transaction.name })
// .single();

// if (data) {
// return {
// ...transaction,
// enrichment_id: data?.id ?? null,
// };
// }
// }

// const result = await processPromisesBatch(
// transactionsData,
// 5,
// enrichTransactions
// );

// const filteredItems = result.filter(Boolean);

// if (filteredItems.length > 0) {
// const { data: updatedTransactions } = await io.supabase.client
// .from("transactions")
// .upsert(filteredItems)
// .select();

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

// await io.logger.info(
// `Transactions Enriched: ${updatedTransactions?.length}`
// );
// }
// }
const { data: transactionsData } = await io.supabase.client
.from("transactions")
.select("id, name")
.eq("team_id", teamId)
.is("category", null)
.is("enrichment_id", null)
.select();

async function enrichTransactions(transaction) {
const { data } = await io.supabase.client
.rpc("search_enriched_transactions", { term: transaction.name })
.single();

if (data) {
return {
...transaction,
enrichment_id: data?.id ?? null,
};
}
}

const result = await processPromisesBatch(
transactionsData,
5,
enrichTransactions
);

const filteredItems = result.filter(Boolean);

if (filteredItems?.length > 0) {
const { data: updatedTransactions } = await io.supabase.client
.from("transactions")
.upsert(filteredItems)
.select();

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

await io.logger.info(
`Transactions Enriched: ${updatedTransactions?.length}`
);
}
}
},
});

Expand Down
2 changes: 1 addition & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"devDependencies": {
"@midday/tsconfig": "workspace:*",
"@types/node": "^20.9.5",
"@types/node": "^20.10.0",
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.17"
}
Expand Down
Binary file modified bun.lockb
Binary file not shown.
18 changes: 0 additions & 18 deletions packages/plaid/package.json

This file was deleted.

32 changes: 0 additions & 32 deletions packages/plaid/src/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/supabase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@supabase/ssr": "^0.0.10",
"@supabase/supabase-js": "^2.38.5",
"supabase": "^1.113.2"
"supabase": "^1.113.3"
},
"devDependencies": {
"typescript": "^5.3.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"clsx": "^2.0.0",
"cmdk": "^0.2.0",
"date-fns": "^2.30.0",
"lucide-react": "^0.292.0",
"lucide-react": "^0.293.0",
"react-day-picker": "^8.9.1",
"react-icons": "^4.12.0",
"tailwind-merge": "^2.0.0",
Expand Down

0 comments on commit 6587a38

Please sign in to comment.