Skip to content

Commit 37e6478

Browse files
authored
Merge pull request #1458 from kenkoooo/revert-1369-PieChart-Only-Rated
Revert "Pie Chartsの表示をRatedとAllで切り替え可能にする"
2 parents 163bb96 + 4d6fbd3 commit 37e6478

File tree

3 files changed

+21
-87
lines changed

3 files changed

+21
-87
lines changed

atcoder-problems-frontend/src/pages/UserPage/CategoryPieChart/index.tsx

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useState } from "react";
2-
import { Row, Col, Button, ButtonGroup } from "reactstrap";
1+
import React from "react";
2+
import { Row, Col } from "reactstrap";
33
import {
44
useContestToProblems,
55
useUserSubmission,
@@ -15,7 +15,6 @@ import {
1515
} from "../../../utils";
1616
import { SmallPieChart } from "../PieChartBlock/SmallPieChart";
1717
import {
18-
isRatedContest,
1918
classifyContest,
2019
ContestCategories,
2120
ContestCategory,
@@ -73,8 +72,7 @@ export const makeCategoryCounts = (
7372
contestsData: Contest[],
7473
contestToProblemsData: Map<string, Problem[]>,
7574
userSubmissionsData: Submission[],
76-
userId: string,
77-
onlyRated: boolean
75+
userId: string
7876
) => {
7977
const contestMap = new Map<string, Contest>(
8078
contestsData.map((contest) => [contest.id, contest])
@@ -120,12 +118,8 @@ export const makeCategoryCounts = (
120118
const category = classifyContest(statusByContest.contest);
121119
statusByContest.problemStatuses.forEach((problemStatus) => {
122120
const formerCount = counts.get(category);
123-
const isRated = isRatedContest(
124-
statusByContest.contest,
125-
contestToProblemsData.get(statusByContest.contest.id)?.length ?? 0
126-
);
127121
if (formerCount === undefined) return;
128-
if (!isRated && onlyRated) return;
122+
129123
statusCounter(formerCount, problemStatus.status);
130124
});
131125
return counts;
@@ -138,23 +132,16 @@ export const CategoryPieChart: React.FC<Props> = (props) => {
138132
const contestToProblems =
139133
useContestToProblems() ?? new Map<ContestId, Problem[]>();
140134
const userSubmissions = useUserSubmission(props.userId) ?? [];
141-
const [onlyRated, setOnlyRated] = useState(true);
142135

143136
const categoryCounts = makeCategoryCounts(
144137
contests,
145138
contestToProblems,
146139
userSubmissions,
147-
props.userId,
148-
onlyRated
140+
props.userId
149141
);
150142

151143
return (
152144
<div>
153-
<ButtonGroup className="mb-2">
154-
<Button onClick={(): void => setOnlyRated(!onlyRated)}>
155-
{onlyRated ? "Only Rated Contests" : "All Contests"}
156-
</Button>
157-
</ButtonGroup>
158145
<Row className="my-3">
159146
{ContestCategories.map((category) => {
160147
const count = categoryCounts.get(category);

atcoder-problems-frontend/src/pages/UserPage/DifficultyPieChart/index.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import React, { useState } from "react";
2-
import { Row, Col, Button, ButtonGroup } from "reactstrap";
3-
import {
4-
useProblemModelMap,
5-
useUserSubmission,
6-
useContestMap,
7-
} from "../../../api/APIClient";
1+
import React from "react";
2+
import { Row, Col } from "reactstrap";
3+
import { useProblemModelMap, useUserSubmission } from "../../../api/APIClient";
84
import {
95
getRatingColor,
106
getRatingColorCode,
@@ -16,7 +12,6 @@ import {
1612
rejectedProblemIdsFromArray,
1713
solvedProblemIdsFromArray,
1814
} from "../UserUtils";
19-
import { isRatedContest } from "../../../utils/ContestClassifier";
2015

2116
interface Props {
2217
userId: string;
@@ -34,15 +29,9 @@ const getPieChartTitle = (ratingColor: RatingColor): string => {
3429
};
3530

3631
export const DifficultyPieChart: React.FC<Props> = (props) => {
37-
const [onlyRated, setOnlyRated] = useState(true);
38-
const contestMap = useContestMap();
32+
const submissions = useUserSubmission(props.userId) ?? [];
3933
const problemModels = useProblemModelMap();
4034
const colorCount = new Map<RatingColor, number>();
41-
const allSubmissions = useUserSubmission(props.userId) ?? [];
42-
const submissions = allSubmissions.filter(
43-
(submission) =>
44-
isRatedContest(contestMap.get(submission.contest_id), 2) || !onlyRated
45-
);
4635
Array.from(problemModels?.values() ?? []).forEach((model) => {
4736
if (model.difficulty !== undefined) {
4837
const color = getRatingColor(model.difficulty);
@@ -89,11 +78,6 @@ export const DifficultyPieChart: React.FC<Props> = (props) => {
8978

9079
return (
9180
<div>
92-
<ButtonGroup className="mb-2">
93-
<Button onClick={(): void => setOnlyRated(!onlyRated)}>
94-
{onlyRated ? "Only Rated Contests" : "All Contests"}
95-
</Button>
96-
</ButtonGroup>
9781
<Row className="my-3">
9882
{data
9983
.filter((e) => e.totalCount > 0)

atcoder-problems-frontend/src/pages/UserPage/PieChartBlock/index.tsx

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { Col, Row, Button, ButtonGroup } from "reactstrap";
2-
import React, { useState } from "react";
1+
import { Col, Row } from "reactstrap";
2+
import React from "react";
33
import {
44
useContestToProblems,
55
useUserSubmission,
6-
useContestMap,
76
} from "../../../api/APIClient";
87
import Problem from "../../../interfaces/Problem";
98
import Submission from "../../../interfaces/Submission";
@@ -13,7 +12,6 @@ import {
1312
isAccepted,
1413
isValidResult,
1514
} from "../../../utils";
16-
import { isRatedContest } from "../../../utils/ContestClassifier";
1715
import { SmallPieChart } from "./SmallPieChart";
1816

1917
enum SubmissionStatus {
@@ -145,26 +143,18 @@ export const PieChartBlock = (props: Props) => {
145143
);
146144
const contestToProblems =
147145
useContestToProblems() ?? new Map<ContestId, Problem[]>();
148-
const [onlyRated, setOnlyRated] = useState(true);
149-
const contestMap = useContestMap();
150146

151147
const abcSolved = solvedCountForPieChart(
152-
Array.from(contestToProblems)
153-
.filter(([contestId]) => contestId.startsWith("abc"))
154-
.filter(
155-
([contestId]) =>
156-
isRatedContest(contestMap.get(contestId), 2) || !onlyRated
157-
),
148+
Array.from(contestToProblems).filter(([contestId]) =>
149+
contestId.startsWith("abc")
150+
),
158151
submissionsMap,
159152
props.userId
160153
);
161154
const arcSolved = solvedCountForPieChart(
162-
Array.from(contestToProblems)
163-
.filter(([contestId]) => contestId.startsWith("arc"))
164-
.filter(
165-
([contestId]) =>
166-
isRatedContest(contestMap.get(contestId), 2) || !onlyRated
167-
),
155+
Array.from(contestToProblems).filter(([contestId]) =>
156+
contestId.startsWith("arc")
157+
),
168158
submissionsMap,
169159
props.userId
170160
);
@@ -177,50 +167,23 @@ export const PieChartBlock = (props: Props) => {
177167
);
178168
return (
179169
<>
180-
<PieCharts
181-
problems={abcSolved}
182-
title="AtCoder Beginner Contest"
183-
setOnlyRated={setOnlyRated}
184-
onlyRated={onlyRated}
185-
/>
186-
<PieCharts
187-
problems={arcSolved}
188-
title="AtCoder Regular Contest"
189-
setOnlyRated={setOnlyRated}
190-
onlyRated={onlyRated}
191-
/>
192-
<PieCharts
193-
problems={agcSolved}
194-
title="AtCoder Grand Contest"
195-
setOnlyRated={setOnlyRated}
196-
onlyRated={onlyRated}
197-
/>
170+
<PieCharts problems={abcSolved} title="AtCoder Beginner Contest" />
171+
<PieCharts problems={arcSolved} title="AtCoder Regular Contest" />
172+
<PieCharts problems={agcSolved} title="AtCoder Grand Contest" />
198173
</>
199174
);
200175
};
201176

202177
interface PieChartsProps {
203178
problems: { total: number; solved: number; rejected: number }[];
204179
title: string;
205-
setOnlyRated: (onlyRated: boolean) => void;
206-
onlyRated: boolean;
207180
}
208181

209-
const PieCharts: React.FC<PieChartsProps> = ({
210-
problems,
211-
title,
212-
setOnlyRated,
213-
onlyRated,
214-
}) => (
182+
const PieCharts: React.FC<PieChartsProps> = ({ problems, title }) => (
215183
<div>
216184
<Row className="my-2 border-bottom">
217185
<h1>{title}</h1>
218186
</Row>
219-
<ButtonGroup className="mb-2">
220-
<Button onClick={(): void => setOnlyRated(!onlyRated)}>
221-
{onlyRated ? "Only Rated Contests" : "All Contests"}
222-
</Button>
223-
</ButtonGroup>
224187
<Row className="my-3">
225188
{problems.map(({ solved, rejected, total }, i) => {
226189
const key = i <= 6 ? "ABCDEFG".charAt(i) : "H/Ex";

0 commit comments

Comments
 (0)