diff --git a/atcoder-problems-frontend/src/pages/ListPage/SmallTable.tsx b/atcoder-problems-frontend/src/pages/ListPage/SmallTable.tsx index 34ec20ed8..314b0e59d 100755 --- a/atcoder-problems-frontend/src/pages/ListPage/SmallTable.tsx +++ b/atcoder-problems-frontend/src/pages/ListPage/SmallTable.tsx @@ -51,25 +51,60 @@ export const SmallTable: React.FC = ({ submissions, setFilterFunc }) => { useMergedProblemMap().data ?? new Map(); const userPointCountMap = getUserPointCounts(mergedProblemMap, submissions); const totalCount = getTotalCount(mergedProblemMap); + const totalCountBy100 = totalCount.reduce( + ( + ret: { point: number; count: number }[], + current: { point: number; count: number } + ) => { + const roundedPoint = Math.floor(current.point / 100) * 100; + const prev = ret.find((entry) => entry.point === roundedPoint); + if (prev) { + prev.count += current.count; + } else { + ret.push({ point: roundedPoint, count: current.count }); + } + return ret; + }, + [] + ); + + const getUserPointCountInArea = ( + countByPoint: Map, + pointStart: number, + pointEnd: number + ) => { + let ret = 0; + for (let i = 0; i < totalCount.length; i++) { + if (totalCount[i].point < pointStart) { + continue; + } + if (totalCount[i].point >= pointEnd) { + break; + } + ret += countByPoint.get(totalCount[i].point) ?? 0; + } + return ret; + }; + return ( - {totalCount.map(({ point }) => ( + {totalCountBy100.map(({ point }) => ( ))} - {totalCount.map(({ point, count }) => ( + {totalCountBy100.map(({ point, count }) => ( ))} @@ -78,16 +113,17 @@ export const SmallTable: React.FC = ({ submissions, setFilterFunc }) => { {userPointCountMap.map(({ userId, countByPoint }) => ( - {totalCount.map(({ point, count }) => ( + {totalCountBy100.map(({ point, count }) => ( ))}
Point setFilterFunc(point)} > - {point} + {`${point}-`}
Total{count}
{userId} - {countByPoint.get(point) ?? 0} + {getUserPointCountInArea(countByPoint, point, point + 100) ?? 0}