From 3563264e0701a48cb99e6ce0a476e2fbeeda64a2 Mon Sep 17 00:00:00 2001 From: CoCo-Japan-pan <115922543+CoCo-Japan-pan@users.noreply.github.com> Date: Fri, 15 Sep 2023 00:23:17 +0900 Subject: [PATCH 1/2] round point status's points by 100 --- .../src/pages/ListPage/SmallTable.tsx | 48 ++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) 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 }) => ( ))} From 05967c45b779006dcd4ab9a479c75e5ba7b9eeba Mon Sep 17 00:00:00 2001 From: CoCo-Japan-pan <115922543+CoCo-Japan-pan@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:08:36 +0900 Subject: [PATCH 2/2] modify filter func --- .../src/pages/ListPage/SmallTable.tsx | 4 ++-- atcoder-problems-frontend/src/pages/ListPage/index.tsx | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/atcoder-problems-frontend/src/pages/ListPage/SmallTable.tsx b/atcoder-problems-frontend/src/pages/ListPage/SmallTable.tsx index 314b0e59d..1f75b8753 100755 --- a/atcoder-problems-frontend/src/pages/ListPage/SmallTable.tsx +++ b/atcoder-problems-frontend/src/pages/ListPage/SmallTable.tsx @@ -10,7 +10,7 @@ import { useMergedProblemMap } from "../../api/APIClient"; interface Props { submissions: Submission[]; - setFilterFunc: (point: number) => void; + setFilterFunc: (from: number, to: number) => void; } export const getTotalCount = ( @@ -95,7 +95,7 @@ export const SmallTable: React.FC = ({ submissions, setFilterFunc }) => {
Point setFilterFunc(point)} > - {point} + {`${point}-`}
Total{count}
{userId} - {countByPoint.get(point) ?? 0} + {getUserPointCountInArea(countByPoint, point, point + 100) ?? 0}
setFilterFunc(point)} + onClick={(): void => setFilterFunc(point, point + 99)} > {`${point}-`} diff --git a/atcoder-problems-frontend/src/pages/ListPage/index.tsx b/atcoder-problems-frontend/src/pages/ListPage/index.tsx index e888c75bd..15ce5233d 100755 --- a/atcoder-problems-frontend/src/pages/ListPage/index.tsx +++ b/atcoder-problems-frontend/src/pages/ListPage/index.tsx @@ -25,12 +25,13 @@ export const ListPage: React.FC = (props) => { const submissions = useMultipleUserSubmissions(users).data ?? []; const progressReset = useProgressResetList().data; - const setExactPointFilter = (point: number): void => { + const setPointFilter = (from: number, to: number): void => { const params = new URLSearchParams(location.search); - params.set(FilterParams.FromPoint, point.toString()); - params.set(FilterParams.ToPoint, point.toString()); + params.set(FilterParams.FromPoint, from.toString()); + params.set(FilterParams.ToPoint, to.toString()); history.push({ ...location, search: params.toString() }); }; + const setDifficultyFilter = (from: number, to: number): void => { const params = new URLSearchParams(location.search); params.set(FilterParams.FromDifficulty, from.toString()); @@ -53,7 +54,7 @@ export const ListPage: React.FC = (props) => {