From 4e1d905c9e7711063a68370db97d181d5d144698 Mon Sep 17 00:00:00 2001 From: Matti Nannt Date: Wed, 5 Jul 2023 15:19:54 +0200 Subject: [PATCH] Fix people service loading time (#485) * Fix people service loading time * run pnpm format --- .../[environmentId]/people/loading.tsx | 57 +++++++++---------- .../[environmentId]/people/page.tsx | 2 +- packages/lib/services/person.ts | 5 +- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/apps/web/app/environments/[environmentId]/people/loading.tsx b/apps/web/app/environments/[environmentId]/people/loading.tsx index f29fd54dae..e85d115325 100644 --- a/apps/web/app/environments/[environmentId]/people/loading.tsx +++ b/apps/web/app/environments/[environmentId]/people/loading.tsx @@ -1,34 +1,31 @@ export default function Loading() { - return ( -
-
-
User
-
User ID
-
Email
+ return ( +
+
+
User
+
User ID
+
Email
+
+
+ {[...Array(3)].map((_, index) => ( +
+
+
+
+
+
+
+
-
- {[...Array(3)].map((_, index) => ( -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ))} +
+
-
- ); +
+
+
+
+ ))} +
+
+ ); } diff --git a/apps/web/app/environments/[environmentId]/people/page.tsx b/apps/web/app/environments/[environmentId]/people/page.tsx index 1d23d93cdb..b7800835d5 100644 --- a/apps/web/app/environments/[environmentId]/people/page.tsx +++ b/apps/web/app/environments/[environmentId]/people/page.tsx @@ -9,7 +9,7 @@ const getAttributeValue = (person: TransformPersonOutput, attributeName: string) person.attributes[attributeName]?.toString(); export default async function PeoplePage({ params }) { - const people = await getPeople(); + const people = await getPeople(params.environmentId); return ( <> diff --git a/packages/lib/services/person.ts b/packages/lib/services/person.ts index 438959d0be..2f9599de71 100644 --- a/packages/lib/services/person.ts +++ b/packages/lib/services/person.ts @@ -70,9 +70,12 @@ export const getPerson = async (personId: string): Promise => { } }; -export const getPeople = cache(async (): Promise => { +export const getPeople = cache(async (environmentId: string): Promise => { try { const personsPrisma = await prisma.person.findMany({ + where: { + environmentId: environmentId, + }, select: { id: true, attributes: {