Skip to content

Commit

Permalink
105 sorting of experts (#108)
Browse files Browse the repository at this point in the history
* changed background of tooltip to transparant

* random

* typecheck errors
  • Loading branch information
JurreBrandsenInfoSupport committed Apr 26, 2024
1 parent 6f06c29 commit dd77c03
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
39 changes: 28 additions & 11 deletions src/app/find-the-expert/[role]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ const ShowTableWrapper = async () => {
dataByRoleAndQuestion[roleName]?.[questionText]?.sort((a, b) => {
const answerValueA = parseInt(a.answer);
const answerValueB = parseInt(b.answer);
return answerValueA - answerValueB;

if (answerValueA === answerValueB) {
// Returns a random value between -0.5 and 0.5
return Math.random() - 0.5;
} else {
// Sort based on answer value
return answerValueA - answerValueB;
}
});
}
}
Expand All @@ -136,18 +143,28 @@ const ShowTableWrapper = async () => {
aggregatedDataByRole[roleName] = {};
}

const answerValue = parseInt(answerOptionMap[entry.answerId] ?? "");
const userName = userMap[entry.userId]?.name ?? "Unknown User";
const userEmail = userMap[entry.userId]?.email ?? "Unknown Email";
if (userMap[entry.userId]) {
const answerValue = parseInt(answerOptionMap[entry.answerId] ?? "", 10);
const userName = userMap[entry.userId]?.name ?? "Unknown User";
const userEmail = userMap[entry.userId]?.email ?? "Unknown Email";
if (!isNaN(answerValue)) {
if (!aggregatedDataByRole[roleName]?.[userEmail]) {
aggregatedDataByRole[roleName]![userEmail] = {
name: userName,
counts: [0, 0, 0, 0],
};
}

if (
!aggregatedDataByRole[roleName]?.[userEmail]?.counts[answerValue]
) {
aggregatedDataByRole[roleName]![userEmail]!.counts[answerValue] = 0;
}

if (!isNaN(answerValue)) {
if (!aggregatedDataByRole[roleName]?.[userEmail]) {
aggregatedDataByRole[roleName]![userEmail] = {
name: userName,
counts: [0, 0, 0, 0],
};
aggregatedDataByRole[roleName]![userEmail]!.counts[answerValue] =
(aggregatedDataByRole[roleName]![userEmail]?.counts[answerValue] ??
0) + 1;
}
aggregatedDataByRole[roleName]![userEmail]!.counts[answerValue]++;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/components/show-results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const ShowResults = ({ data }: { data: TransformedData }) => {
}}
/>
<Tooltip
cursor={{ fill: "transparent" }}
content={
<CustomTooltip active={false} payload={[]} />
}
Expand Down

0 comments on commit dd77c03

Please sign in to comment.