feat(frontend): add visual indicator to top lists

This commit is contained in:
Julian Tölle 2021-05-22 17:32:20 +02:00
parent 3228b22741
commit 8377b2f6d0
6 changed files with 79 additions and 13 deletions

View file

@ -0,0 +1,11 @@
interface TopListItemEntity {
count: number;
}
/**
* Get max count for top list. Returns at least 1 to make sure we do not run into issues
* with empty list (would normally return -Infinity) or 0 (could cause divide by zero error).
*/
export function getMaxCount(items: TopListItemEntity[]): number {
return Math.max(1, ...items.map(({ count }) => count));
}