diff --git a/packages/nextjs/components/impact-vector/ImpactVectorGraph.tsx b/packages/nextjs/components/impact-vector/ImpactVectorGraph.tsx index 6d33d8a..e5f002d 100644 --- a/packages/nextjs/components/impact-vector/ImpactVectorGraph.tsx +++ b/packages/nextjs/components/impact-vector/ImpactVectorGraph.tsx @@ -64,7 +64,7 @@ const transformData = (impactData: DataSet[]): any[] => { // Function to sort array in descending order based on opAllocation const sortByTotalDescending = (dataSetArray: any[]) => { - return dataSetArray.slice().sort((a, b) => b.opAllocation - a.opAllocation); + return dataSetArray.slice().sort((a, b) => a.opAllocation - b.opAllocation); }; export default function ImpactVectorGraph({ diff --git a/packages/nextjs/pages/api/impact/index.ts b/packages/nextjs/pages/api/impact/index.ts index c3af517..d2ddae9 100644 --- a/packages/nextjs/pages/api/impact/index.ts +++ b/packages/nextjs/pages/api/impact/index.ts @@ -53,14 +53,14 @@ async function getImpact(vectorWeights: VectorWeight[]) { const allProjects = await getProjects(); const scoredProjects = await scoreProjectsByVectorWeight({ allProjects, vectorWeights }); - const nonZeroProjects = scoredProjects.filter(project => project.score > 0); - // Calculate total OP allocated to each project - const totalScore = nonZeroProjects.reduce((total, curr) => total + curr.score, 0); - const projectsWithOPAllocated = nonZeroProjects.map(project => ({ - ...project, - opAllocation: (project.score / totalScore) * 10000000, - })); + const totalScore = scoredProjects.reduce((total, curr) => total + curr.score, 0); + const projectsWithOPAllocated = scoredProjects + .map(project => ({ + ...project, + opAllocation: (project.score / totalScore) * 10000000, + })) + .filter(project => project.opAllocation >= 1); return projectsWithOPAllocated; }