From fa117870a21cce5ebcfb072bb8b462a96246ee29 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 9 Dec 2024 21:52:32 -0500 Subject: [PATCH] perf: One less query in documents.info --- server/routes/api/documents/documents.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/routes/api/documents/documents.ts b/server/routes/api/documents/documents.ts index 2e9b06f3d6..2c20b97fb2 100644 --- a/server/routes/api/documents/documents.ts +++ b/server/routes/api/documents/documents.ts @@ -573,12 +573,13 @@ router.post( teamId: teamFromCtx?.id, }); const isPublic = cannot(user, "read", document); - const serializedDocument = await presentDocument(ctx, document, { - isPublic, - shareId, - }); - - const team = await document.$get("team"); + const [serializedDocument, team] = await Promise.all([ + presentDocument(ctx, document, { + isPublic, + shareId, + }), + teamFromCtx?.id === document.teamId ? teamFromCtx : document.$get("team"), + ]); // Passing apiVersion=2 has a single effect, to change the response payload to // include top level keys for document, sharedTree, and team.