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";