2
0

🐛 (analytics) Add better completion rate parsing (#258)

Closes #244
This commit is contained in:
Jorgelig
2023-01-16 11:19:15 -06:00
committed by GitHub
parent 67ee197d9b
commit cf5520b0d8

View File

@ -10,6 +10,14 @@ import {
import { Stats } from 'models'
import React from 'react'
const computeCompletionRate = (
totalCompleted: number,
totalStarts: number
): string => {
if (totalStarts === 0) return 'Not available'
return `${Math.round((totalCompleted / totalStarts) * 100)}%`
}
export const StatsCards = ({
stats,
...props
@ -38,7 +46,7 @@ export const StatsCards = ({
<StatLabel>Completion rate</StatLabel>
{stats ? (
<StatNumber>
{Math.round((stats.totalCompleted / stats.totalStarts) * 100)}%
{computeCompletionRate(stats.totalCompleted, stats.totalStarts)}
</StatNumber>
) : (
<Skeleton w="50%" h="10px" mt="2" />