diff --git a/app/api/interests/route.ts b/app/api/interests/route.ts index c2dc808e..a733a23b 100644 --- a/app/api/interests/route.ts +++ b/app/api/interests/route.ts @@ -4,7 +4,7 @@ import { NextResponse } from "next/server"; export async function GET() { try { // Get all interests from the database - const cacheStrategy = { swr: 60, ttl: 60 }; + const cacheStrategy = { swr: 60, ttl: 60, tags: ["interests"] }; const interests = await prisma.interest.findMany({ select: { id: true, diff --git a/app/api/profiles/[id]/route.ts b/app/api/profiles/[id]/route.ts index 5311037d..a698b906 100644 --- a/app/api/profiles/[id]/route.ts +++ b/app/api/profiles/[id]/route.ts @@ -9,6 +9,7 @@ export async function GET( const params = await context.params; const { id } = params; + const cacheStrategy = { swr: 3600, ttl: 3600, tags: ["profiles/[id]"] }; const user = await prisma.user.findUnique({ where: { id }, select: { @@ -26,6 +27,7 @@ export async function GET( }, }, }, + cacheStrategy: cacheStrategy, }); // If user not found, return 404 diff --git a/app/api/profiles/route.ts b/app/api/profiles/route.ts index cdad5c63..d0036b26 100644 --- a/app/api/profiles/route.ts +++ b/app/api/profiles/route.ts @@ -84,7 +84,7 @@ export async function GET(request: Request) { } // Fetch paginated and filtered profiles - const cacheStrategy = { swr: 3600, ttl: 3600 }; + const cacheStrategy = { swr: 3600, ttl: 3600 , tags: ["profiles"]}; const profiles = await prisma.user.findMany({ skip: offset, take: profilesPerPage, diff --git a/prisma/seed.ts b/prisma/seed.ts index 8af5f2f1..b4c1cbbd 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -1,7 +1,11 @@ -import {prisma} from "@/lib/server/prisma"; +import {PrismaClient} from "@prisma/client"; + +// Cannot import from prisma.ts as we are outside the server +const prisma = new PrismaClient({log: ['query']}) async function main() { + // Create some interests and cause areas await prisma.interest.createMany({ data: [ @@ -31,17 +35,25 @@ async function main() { skipDuplicates: true, }); + const names = [ + 'Alice Wonderland', + 'Bob the Builder', + 'Emily McConaughey', + 'Alex Hepburn', + 'Laurent Golden' + ] + // Get actual Interest & CauseArea objects const allInterests = await prisma.interest.findMany(); const allCauseAreas = await prisma.causeArea.findMany(); const allConnections = await prisma.connection.findMany(); // Create mock users - for (let i = 1; i <= 5; i++) { + for (let i = 0; i < 5; i++) { const user = await prisma.user.create({ data: { - email: `user${i}@bayesbond.com`, - name: `User ${i}`, + email: `user${i+1}@bayesbond.com`, + name: names[i], image: null, profile: { create: {