Skip to content

Commit

Permalink
Merge pull request #95 from escottalexander/graph-adjustments
Browse files Browse the repository at this point in the history
Graph adjustments
  • Loading branch information
escottalexander authored Apr 15, 2024
2 parents aa715c0 + 43619d6 commit 101b1ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
14 changes: 7 additions & 7 deletions packages/nextjs/pages/api/impact/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 101b1ae

Please sign in to comment.