diff --git a/frontend/src/routes/(app)/+page.server.ts b/frontend/src/routes/(app)/+page.server.ts index 29de605..d4c7212 100644 --- a/frontend/src/routes/(app)/+page.server.ts +++ b/frontend/src/routes/(app)/+page.server.ts @@ -1,11 +1,19 @@ import { redirect } from '@sveltejs/kit' import type { PageServerLoad, Actions } from './$types' import { db } from '$lib/db' +import { sql } from 'drizzle-orm' export const load = (async (event) => { const user = event.locals.userObject const projects = await db.query.project.findMany({ + with: { + shortener: { + with: { + visitor: true, + }, + }, + }, where: (project, { eq }) => eq(project.userId, user.id), }) diff --git a/frontend/src/routes/(app)/+page.svelte b/frontend/src/routes/(app)/+page.svelte index 464832b..8f4b8d4 100644 --- a/frontend/src/routes/(app)/+page.svelte +++ b/frontend/src/routes/(app)/+page.svelte @@ -2,6 +2,7 @@ import type { PageData } from './$types' import * as Card from '$lib/components/ui/card' import { Button } from '$lib/components/ui/button' + import { BarChart } from 'lucide-svelte' export let data: PageData @@ -20,11 +21,20 @@ Projects - + {#each data.projects as project} - - {project.name} - + + + {project.name} + + + + {project.shortener.reduce( + (curr, shortener) => shortener.visitor.length + curr, + 0, + )} visits + + {/each}