Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions frontend/src/ts/components/pages/connections/FriendsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,26 @@ function getColumns({
defineColumn("completedTests", {
enableSorting: true,
header: "tests",
cell: (info) => `${info.getValue()}/${info.row.original.startedTests}`,
cell: (info) => {
const completedTests = info.getValue<number | undefined>();
const startedTests = info.row.original.startedTests;

return completedTests === undefined || startedTests === undefined
? "-"
: `${completedTests}/${startedTests}`;
Comment on lines +186 to +188

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to this?

return `${completedTests ?? 0}/${startedTests ?? 0}`;

},
meta: {
breakpoint: "lg",
cellMeta: ({ row }) => {
const testStats = formatTypingStatsRatio(row);

if (testStats.completedPercentage === "") {
return {};
}

return {
"data-balloon-pos": "up",
"aria-label": `${testStats.completedPercentage}% (${
testStats.restartRatio
} restarts per completed test)`,
"aria-label": `${testStats.completedPercentage}% (${testStats.restartRatio} restarts per completed test)`,
};
},
},
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/ts/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,10 +726,13 @@ export function formatTypingStatsRatio(stats: {
completedPercentage: Math.floor(
(stats.completedTests / stats.startedTests) * 100,
).toString(),
restartRatio: (
(stats.startedTests - stats.completedTests) /
stats.completedTests
).toFixed(1),
restartRatio:
stats.completedTests === 0
? "-"
: (
(stats.startedTests - stats.completedTests) /
stats.completedTests
).toFixed(1),
Comment on lines +729 to +735

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract to a const to make it more readable

};
}

Expand Down
Loading