Skip to content

Commit 3614073

Browse files
committed
Ranking fixed
1 parent eced007 commit 3614073

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/sections/projectSection/components/EvaluatedList.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,20 @@ function EvaluatedList({ projects }) {
9595

9696
const filteredProjects = newProjects.filter((project) => {
9797
if (filter === 0) {
98-
return project.status === 1 && project.project_evaluation !== 0;
98+
// return project.status === 1 && project.project_evaluation !== 0;
99+
return projects && project.project_evaluation !== 0;
99100
} else if (filter === 1) {
100101
return (
101102
project.categorization.infrastructure === true &&
102-
project.status === 1 &&
103+
// project.status === 1 &&
104+
projects &&
103105
project.project_evaluation !== 0
104106
);
105107
} else if (filter === 2) {
106108
return (
107109
project.categorization.infrastructure === false &&
108-
project.status === 1 &&
110+
// project.status === 1 &&
111+
projects &&
109112
project.project_evaluation !== 0
110113
);
111114
}
@@ -116,12 +119,20 @@ function EvaluatedList({ projects }) {
116119
(a, b) => b.project_evaluation - a.project_evaluation
117120
);
118121

119-
let currentRank = 1;
120122
const rankedProjects = sortedProjects.map((project, index) => {
121-
if (index > 0 && project.project_evaluation !== sortedProjects[index - 1].project_evaluation) {
122-
currentRank = index + 1;
123+
if (index === 0) {
124+
project.rank = 1;
125+
} else if (
126+
project.project_evaluation ===
127+
sortedProjects[index - 1].project_evaluation
128+
) {
129+
// same score = same rank
130+
project.rank = sortedProjects[index - 1].rank;
131+
} else {
132+
// new score = +1 rank
133+
project.rank = sortedProjects[index - 1].rank + 1;
123134
}
124-
return { ...project, rank: currentRank };
135+
return project;
125136
});
126137

127138
return (

0 commit comments

Comments
 (0)