diff --git a/apps/frontend/app/project/[...slug]/page.tsx b/apps/frontend/app/project/[...slug]/page.tsx index 200a504a4..b235db804 100644 --- a/apps/frontend/app/project/[...slug]/page.tsx +++ b/apps/frontend/app/project/[...slug]/page.tsx @@ -62,32 +62,44 @@ export default async function ProjectPage(props: ProjectPageProps) { notFound(); } const project = projectArray[0]; + const projectId = project.project_id; //console.log("project", project); - const { event_types: eventTypes } = await cachedGetAllEventTypes(); - const { code_metrics_by_project: codeMetrics } = - await cachedGetCodeMetricsByProjectIds({ - project_ids: [project.project_id], - }); - const { onchain_metrics_by_project: onchainMetrics } = - await cachedGetOnchainMetricsByProjectIds({ - project_ids: [project.project_id], - }); - const { artifacts_by_project: artifactIds } = - await cachedGetArtifactIdsByProjectIds({ - project_ids: [project.project_id], - }); - const { projects_by_collection: collectionIds } = - await cachedGetCollectionIdsByProjectIds({ - project_ids: [project.project_id], - }); - const { artifacts } = await cachedGetArtifactsByIds({ - artifact_ids: artifactIds.map((x: any) => x.artifact_id), - }); - const { collections } = await cachedGetCollectionsByIds({ - collection_ids: collectionIds.map((x: any) => x.collection_id), - }); + // Parallelize getting things related to the project + const p1 = await Promise.all([ + cachedGetAllEventTypes(), + cachedGetCodeMetricsByProjectIds({ + project_ids: [projectId], + }), + cachedGetOnchainMetricsByProjectIds({ + project_ids: [projectId], + }), + cachedGetArtifactIdsByProjectIds({ + project_ids: [projectId], + }), + cachedGetCollectionIdsByProjectIds({ + project_ids: [projectId], + }), + ]); + const { event_types: eventTypes } = p1[0]; + const { code_metrics_by_project: codeMetrics } = p1[1]; + const { onchain_metrics_by_project: onchainMetrics } = p1[2]; + const { artifacts_by_project: artifactIds } = p1[3]; + const { projects_by_collection: collectionIds } = p1[4]; + + // Parallelize getting artifacts and collections + const p2 = await Promise.all([ + cachedGetArtifactsByIds({ + artifact_ids: artifactIds.map((x: any) => x.artifact_id), + }), + cachedGetCollectionsByIds({ + collection_ids: collectionIds.map((x: any) => x.collection_id), + }), + ]); + const { artifacts } = p2[0]; + const { collections } = p2[1]; + // Get Plasmic component const plasmicData = await cachedFetchComponent(PLASMIC_COMPONENT); const compMeta = plasmicData.entryCompMetas[0];