Fix percentages.

This commit is contained in:
Brian Cao 2024-05-05 22:28:18 -07:00
parent 60e7257656
commit 4d66d400a9
2 changed files with 7 additions and 4 deletions

View File

@ -33,10 +33,13 @@ export function GoalsChart({ className }: { className?: string; isLoading?: bool
<span className={styles.visitors}>{formatLongNumber(goal)}</span>
{formatMessage(labels.goal)}
</div>
<div className={styles.percent}>{(result / goal).toFixed(2)}%</div>
<div className={styles.percent}>{((result / goal) * 100).toFixed(2)}%</div>
</div>
<div className={styles.track}>
<div className={styles.bar} style={{ width: `${result / goal}%` }}></div>
<div
className={styles.bar}
style={{ width: `${result > goal ? 100 : (result / goal) * 100}%` }}
></div>
</div>
</div>
</div>

View File

@ -196,7 +196,7 @@ async function clickhouseQuery(
const results = a[0];
return Object.keys(results).map((key, i) => {
return { ...urls[i], result: results[key] };
return { ...urls[i], goal: Number(urls[i].goal), result: Number(results[key]) };
});
})
: [];
@ -216,7 +216,7 @@ async function clickhouseQuery(
const results = a[0];
return Object.keys(results).map((key, i) => {
return { ...events[i], result: results[key] };
return { ...events[i], goal: Number(events[i].goal), result: Number(results[key]) };
});
})
: [];