Skip to content

Commit e62435a

Browse files
authored
Merge pull request #1142 from kenkoooo/pr/southball/1110
頑張ってマージ
2 parents 7687f66 + 7313fe5 commit e62435a

File tree

22 files changed

+102
-61
lines changed

22 files changed

+102
-61
lines changed

atcoder-problems-frontend/src/api/APIClient.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import MergedProblem, { isMergedProblem } from "../interfaces/MergedProblem";
55
import Problem, { isProblem } from "../interfaces/Problem";
66
import ProblemModel, { isProblemModel } from "../interfaces/ProblemModel";
77
import { isRankingEntry, RankingEntry } from "../interfaces/RankingEntry";
8-
import { ContestId, ProblemId, UserId } from "../interfaces/Status";
8+
import {
9+
ContestId,
10+
ProblemId,
11+
ProblemIndex,
12+
UserId,
13+
} from "../interfaces/Status";
914
import { isSubmission } from "../interfaces/Submission";
1015
import { isUserRankEntry, UserRankEntry } from "../interfaces/UserRankEntry";
1116
import { clipDifficulty, isValidResult } from "../utils";
@@ -188,9 +193,16 @@ const useContestProblemList = () => {
188193
return useSWRData(url, (url) =>
189194
fetchTypedArray(
190195
url,
191-
(obj): obj is { contest_id: ContestId; problem_id: ProblemId } =>
196+
(
197+
obj
198+
): obj is {
199+
contest_id: ContestId;
200+
problem_id: ProblemId;
201+
problem_index: ProblemIndex;
202+
} =>
192203
hasPropertyAsType(obj, "contest_id", isString) &&
193-
hasPropertyAsType(obj, "problem_id", isString)
204+
hasPropertyAsType(obj, "problem_id", isString) &&
205+
hasPropertyAsType(obj, "problem_index", isString)
194206
)
195207
);
196208
};
@@ -199,11 +211,11 @@ export const useContestToProblems = () => {
199211
const contestIdToProblemIdArray = useContestProblemList();
200212
const problemMap = useProblemMap();
201213
return contestIdToProblemIdArray.data?.reduce(
202-
(map, { contest_id, problem_id }) => {
214+
(map, { contest_id, problem_id, problem_index }) => {
203215
const problem = problemMap?.get(problem_id);
204216
if (problem) {
205217
const problems = map.get(contest_id) ?? [];
206-
problems.push(problem);
218+
problems.push({ ...problem, problem_index });
207219
map.set(contest_id, problems);
208220
}
209221
return map;
@@ -216,11 +228,11 @@ export const useContestToMergedProblems = () => {
216228
const contestIdToProblemIdArray = useContestProblemList();
217229
const { data: problemMap } = useMergedProblemMap();
218230
return contestIdToProblemIdArray.data?.reduce(
219-
(map, { contest_id, problem_id }) => {
231+
(map, { contest_id, problem_id, problem_index }) => {
220232
const problem = problemMap?.get(problem_id);
221233
if (problem) {
222234
const problems = map.get(contest_id) ?? [];
223-
problems.push(problem);
235+
problems.push({ ...problem, problem_index });
224236
map.set(contest_id, problems);
225237
}
226238
return map;

atcoder-problems-frontend/src/components/ProblemLink.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ interface Props {
1111
className?: string;
1212
problemId: string;
1313
contestId: string;
14-
problemTitle: string;
14+
problemIndex?: string;
15+
problemName: string;
1516
showDifficulty?: boolean;
1617
isExperimentalDifficulty?: boolean;
1718
showDifficultyUnavailable?: boolean;
@@ -25,13 +26,18 @@ export const ProblemLink: React.FC<Props> = (props) => {
2526
const {
2627
contestId,
2728
problemId,
28-
problemTitle,
29+
problemIndex,
30+
problemName,
2931
showDifficulty,
3032
isExperimentalDifficulty,
3133
showDifficultyUnavailable,
3234
problemModel,
3335
userRatingInfo,
3436
} = props;
37+
const problemTitle = problemIndex
38+
? `${problemIndex}. ${problemName}`
39+
: problemName;
40+
3541
const link = (
3642
<NewTabLink
3743
href={Url.formatProblemUrl(problemId, contestId)}

atcoder-problems-frontend/src/components/ProblemSearchBox.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const problemMatch = (text: string, problem: Problem): boolean => {
1717
.every(
1818
(word) =>
1919
(word.trim().length > 0 &&
20-
problem.title.toLowerCase().includes(word.toLowerCase())) ||
20+
problem.name.toLowerCase().includes(word.toLowerCase())) ||
2121
formatProblemUrl(problem.id, problem.contest_id)
2222
.toLowerCase()
2323
.includes(word.toLowerCase())
@@ -76,7 +76,9 @@ export const ProblemSearchBox: React.FC<Props> = (props) => {
7676
setFocusingId(-1);
7777
}}
7878
>
79-
<ListGroupItemHeading>{problem.title}</ListGroupItemHeading>
79+
<ListGroupItemHeading>
80+
{problem.problem_index}. {problem.name}
81+
</ListGroupItemHeading>
8082
<ListGroupItemText>
8183
{formatProblemUrl(problem.id, problem.contest_id)}
8284
</ListGroupItemText>

atcoder-problems-frontend/src/components/SubmissionListTable.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ export const SubmissionListTable: React.FC<Props> = (props) => {
2323
const { submissions, userRatingInfo } = props;
2424
const problems = useProblems() ?? [];
2525
const problemModels = useProblemModelMap();
26-
const titleMap = problems.reduce((map, p) => {
27-
map.set(p.id, p.title);
28-
return map;
29-
}, new Map<string, string>());
26+
const [problemIndexMap, nameMap] = problems.reduce(
27+
([problemIndexMap, nameMap], p) => {
28+
problemIndexMap.set(p.id, p.problem_index);
29+
nameMap.set(p.id, p.name);
30+
return [problemIndexMap, nameMap];
31+
},
32+
[new Map<string, string>(), new Map<string, string>()]
33+
);
3034

3135
const verdictOptions: { [_: string]: string } = Array.from(
3236
submissions.reduce((set, s) => {
@@ -56,7 +60,11 @@ export const SubmissionListTable: React.FC<Props> = (props) => {
5660
<BootstrapTable
5761
data={submissions
5862
.sort((a, b) => b.epoch_second - a.epoch_second)
59-
.map((s) => ({ title: titleMap.get(s.problem_id), ...s }))}
63+
.map((s) => ({
64+
problemIndex: problemIndexMap.get(s.problem_id) ?? "",
65+
name: nameMap.get(s.problem_id) ?? "",
66+
...s,
67+
}))}
6068
keyField="id"
6169
height="auto"
6270
hover
@@ -107,9 +115,9 @@ export const SubmissionListTable: React.FC<Props> = (props) => {
107115
<TableHeaderColumn
108116
filterFormatted
109117
dataSort
110-
dataField="title"
118+
dataField="name"
111119
dataFormat={(
112-
title: string | undefined,
120+
name: string | undefined,
113121
{ problem_id, contest_id }: Submission
114122
): React.ReactElement => (
115123
<ProblemLink
@@ -118,7 +126,8 @@ export const SubmissionListTable: React.FC<Props> = (props) => {
118126
}
119127
showDifficulty={true}
120128
problemId={problem_id}
121-
problemTitle={title || ""}
129+
problemIndex={problemIndexMap.get(problem_id) || ""}
130+
problemName={name || ""}
122131
contestId={contest_id}
123132
problemModel={problemModels?.get(problem_id) ?? null}
124133
userRatingInfo={userRatingInfo}

atcoder-problems-frontend/src/interfaces/MergedProblem.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export default interface MergedProblem {
1111
// Basic information
1212
readonly id: string;
1313
readonly contest_id: string;
14-
readonly title: string;
14+
readonly problem_index: string;
15+
readonly name: string;
1516

1617
// Information for first AC
1718
readonly first_user_id: string | null;
@@ -39,7 +40,8 @@ export const isMergedProblem = (obj: unknown): obj is MergedProblem =>
3940
obj !== null &&
4041
hasPropertyAsType(obj, "id", isString) &&
4142
hasPropertyAsType(obj, "contest_id", isString) &&
42-
hasPropertyAsType(obj, "title", isString) &&
43+
hasPropertyAsType(obj, "problem_index", isString) &&
44+
hasPropertyAsType(obj, "name", isString) &&
4345
hasPropertyAsTypeOrNull(obj, "first_user_id", isString) &&
4446
hasPropertyAsTypeOrNull(obj, "first_contest_id", isString) &&
4547
hasPropertyAsTypeOrNull(obj, "first_submission_id", isNumber) &&

atcoder-problems-frontend/src/interfaces/Problem.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import { hasPropertyAsType, isString } from "../utils/TypeUtils";
44
export default interface Problem {
55
readonly id: string;
66
readonly contest_id: string;
7-
readonly title: string;
7+
readonly problem_index: string;
8+
readonly name: string;
89
}
910

1011
export const isProblem = (obj: unknown): obj is Problem =>
1112
hasPropertyAsType(obj, "id", isString) &&
1213
hasPropertyAsType(obj, "contest_id", isString) &&
13-
hasPropertyAsType(obj, "title", isString);
14+
hasPropertyAsType(obj, "problem_index", isString) &&
15+
hasPropertyAsType(obj, "name", isString);

atcoder-problems-frontend/src/interfaces/Status.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { caseInsensitiveUserId, isAccepted } from "../utils";
22
import Submission from "./Submission";
33
export type ContestId = string;
44
export type ProblemId = string;
5+
export type ProblemIndex = string;
56
export type UserId = string;
67

78
export enum StatusLabel {

atcoder-problems-frontend/src/pages/Internal/MyAccountPage/ResetProgress.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export const ResetProgress: React.FC = () => {
5252
<ProblemLink
5353
problemId={problem.id}
5454
contestId={problem.contest_id}
55-
problemTitle={problem.title}
55+
problemIndex={problem.problem_index}
56+
problemName={problem.name}
5657
/>
5758
) : (
5859
item.problem_id

atcoder-problems-frontend/src/pages/Internal/ProblemList/SingleProblemList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ const ProblemEntry: React.FC<{
188188
<ListGroupItemHeading>
189189
{problem ? (
190190
<NewTabLink href={formatProblemUrl(problem.id, problem.contest_id)}>
191-
{problem.title}
191+
{problem.problem_index}. {problem.name}
192192
</NewTabLink>
193193
) : (
194194
item.problem_id

atcoder-problems-frontend/src/pages/Internal/VirtualContest/DraggableContestConfigProblemTable/ProblemCell.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export const ProblemCell: React.FC<ProblemCellProps> = ({
2222
<ProblemLink
2323
problemId={problem.id}
2424
contestId={problem.contest_id}
25-
problemTitle={problem.title}
25+
problemIndex={problem.problem_index}
26+
problemName={problem.name}
2627
showDifficulty={true}
2728
problemModel={problemModel}
2829
isExperimentalDifficulty={problemModel?.is_experimental}

0 commit comments

Comments
 (0)