From 4d6fbd391a1a2695af3e0e9f47693ee599f4c3b9 Mon Sep 17 00:00:00 2001 From: kenkoooo Date: Fri, 24 Nov 2023 09:11:21 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"Pie=20Charts=E3=81=AE=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=82=92Rated=E3=81=A8All=E3=81=A7=E5=88=87=E3=82=8A?= =?UTF-8?q?=E6=9B=BF=E3=81=88=E5=8F=AF=E8=83=BD=E3=81=AB=E3=81=99=E3=82=8B?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/UserPage/CategoryPieChart/index.tsx | 23 ++----- .../UserPage/DifficultyPieChart/index.tsx | 24 ++------ .../pages/UserPage/PieChartBlock/index.tsx | 61 ++++--------------- 3 files changed, 21 insertions(+), 87 deletions(-) diff --git a/atcoder-problems-frontend/src/pages/UserPage/CategoryPieChart/index.tsx b/atcoder-problems-frontend/src/pages/UserPage/CategoryPieChart/index.tsx index f0ac77526..a099dd63e 100644 --- a/atcoder-problems-frontend/src/pages/UserPage/CategoryPieChart/index.tsx +++ b/atcoder-problems-frontend/src/pages/UserPage/CategoryPieChart/index.tsx @@ -1,5 +1,5 @@ -import React, { useState } from "react"; -import { Row, Col, Button, ButtonGroup } from "reactstrap"; +import React from "react"; +import { Row, Col } from "reactstrap"; import { useContestToProblems, useUserSubmission, @@ -15,7 +15,6 @@ import { } from "../../../utils"; import { SmallPieChart } from "../PieChartBlock/SmallPieChart"; import { - isRatedContest, classifyContest, ContestCategories, ContestCategory, @@ -73,8 +72,7 @@ export const makeCategoryCounts = ( contestsData: Contest[], contestToProblemsData: Map, userSubmissionsData: Submission[], - userId: string, - onlyRated: boolean + userId: string ) => { const contestMap = new Map( contestsData.map((contest) => [contest.id, contest]) @@ -120,12 +118,8 @@ export const makeCategoryCounts = ( const category = classifyContest(statusByContest.contest); statusByContest.problemStatuses.forEach((problemStatus) => { const formerCount = counts.get(category); - const isRated = isRatedContest( - statusByContest.contest, - contestToProblemsData.get(statusByContest.contest.id)?.length ?? 0 - ); if (formerCount === undefined) return; - if (!isRated && onlyRated) return; + statusCounter(formerCount, problemStatus.status); }); return counts; @@ -138,23 +132,16 @@ export const CategoryPieChart: React.FC = (props) => { const contestToProblems = useContestToProblems() ?? new Map(); const userSubmissions = useUserSubmission(props.userId) ?? []; - const [onlyRated, setOnlyRated] = useState(true); const categoryCounts = makeCategoryCounts( contests, contestToProblems, userSubmissions, - props.userId, - onlyRated + props.userId ); return (
- - - {ContestCategories.map((category) => { const count = categoryCounts.get(category); diff --git a/atcoder-problems-frontend/src/pages/UserPage/DifficultyPieChart/index.tsx b/atcoder-problems-frontend/src/pages/UserPage/DifficultyPieChart/index.tsx index 122820b26..174871d3c 100644 --- a/atcoder-problems-frontend/src/pages/UserPage/DifficultyPieChart/index.tsx +++ b/atcoder-problems-frontend/src/pages/UserPage/DifficultyPieChart/index.tsx @@ -1,10 +1,6 @@ -import React, { useState } from "react"; -import { Row, Col, Button, ButtonGroup } from "reactstrap"; -import { - useProblemModelMap, - useUserSubmission, - useContestMap, -} from "../../../api/APIClient"; +import React from "react"; +import { Row, Col } from "reactstrap"; +import { useProblemModelMap, useUserSubmission } from "../../../api/APIClient"; import { getRatingColor, getRatingColorCode, @@ -16,7 +12,6 @@ import { rejectedProblemIdsFromArray, solvedProblemIdsFromArray, } from "../UserUtils"; -import { isRatedContest } from "../../../utils/ContestClassifier"; interface Props { userId: string; @@ -34,15 +29,9 @@ const getPieChartTitle = (ratingColor: RatingColor): string => { }; export const DifficultyPieChart: React.FC = (props) => { - const [onlyRated, setOnlyRated] = useState(true); - const contestMap = useContestMap(); + const submissions = useUserSubmission(props.userId) ?? []; const problemModels = useProblemModelMap(); const colorCount = new Map(); - const allSubmissions = useUserSubmission(props.userId) ?? []; - const submissions = allSubmissions.filter( - (submission) => - isRatedContest(contestMap.get(submission.contest_id), 2) || !onlyRated - ); Array.from(problemModels?.values() ?? []).forEach((model) => { if (model.difficulty !== undefined) { const color = getRatingColor(model.difficulty); @@ -89,11 +78,6 @@ export const DifficultyPieChart: React.FC = (props) => { return (
- - - {data .filter((e) => e.totalCount > 0) diff --git a/atcoder-problems-frontend/src/pages/UserPage/PieChartBlock/index.tsx b/atcoder-problems-frontend/src/pages/UserPage/PieChartBlock/index.tsx index fe5d7b0c8..33f882db7 100644 --- a/atcoder-problems-frontend/src/pages/UserPage/PieChartBlock/index.tsx +++ b/atcoder-problems-frontend/src/pages/UserPage/PieChartBlock/index.tsx @@ -1,9 +1,8 @@ -import { Col, Row, Button, ButtonGroup } from "reactstrap"; -import React, { useState } from "react"; +import { Col, Row } from "reactstrap"; +import React from "react"; import { useContestToProblems, useUserSubmission, - useContestMap, } from "../../../api/APIClient"; import Problem from "../../../interfaces/Problem"; import Submission from "../../../interfaces/Submission"; @@ -13,7 +12,6 @@ import { isAccepted, isValidResult, } from "../../../utils"; -import { isRatedContest } from "../../../utils/ContestClassifier"; import { SmallPieChart } from "./SmallPieChart"; enum SubmissionStatus { @@ -145,26 +143,18 @@ export const PieChartBlock = (props: Props) => { ); const contestToProblems = useContestToProblems() ?? new Map(); - const [onlyRated, setOnlyRated] = useState(true); - const contestMap = useContestMap(); const abcSolved = solvedCountForPieChart( - Array.from(contestToProblems) - .filter(([contestId]) => contestId.startsWith("abc")) - .filter( - ([contestId]) => - isRatedContest(contestMap.get(contestId), 2) || !onlyRated - ), + Array.from(contestToProblems).filter(([contestId]) => + contestId.startsWith("abc") + ), submissionsMap, props.userId ); const arcSolved = solvedCountForPieChart( - Array.from(contestToProblems) - .filter(([contestId]) => contestId.startsWith("arc")) - .filter( - ([contestId]) => - isRatedContest(contestMap.get(contestId), 2) || !onlyRated - ), + Array.from(contestToProblems).filter(([contestId]) => + contestId.startsWith("arc") + ), submissionsMap, props.userId ); @@ -177,24 +167,9 @@ export const PieChartBlock = (props: Props) => { ); return ( <> - - - + + + ); }; @@ -202,25 +177,13 @@ export const PieChartBlock = (props: Props) => { interface PieChartsProps { problems: { total: number; solved: number; rejected: number }[]; title: string; - setOnlyRated: (onlyRated: boolean) => void; - onlyRated: boolean; } -const PieCharts: React.FC = ({ - problems, - title, - setOnlyRated, - onlyRated, -}) => ( +const PieCharts: React.FC = ({ problems, title }) => (

{title}

- - - {problems.map(({ solved, rejected, total }, i) => { const key = i <= 6 ? "ABCDEFG".charAt(i) : "H/Ex";