Skip to content

Commit f9e01e6

Browse files
committed
added filter for virtual contests problems.
1 parent dda1252 commit f9e01e6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ import {
1616
} from "reactstrap";
1717
import React, { useState } from "react";
1818
import {
19+
useContests,
1920
useMultipleUserSubmissions,
2021
useProblemModelMap,
2122
useProblems,
2223
} from "../api/APIClient";
2324
import Problem from "../interfaces/Problem";
25+
import Contest from "../interfaces/Contest";
2426
import { shuffleArray } from "../utils";
2527
import {
2628
ExcludeOption,
@@ -30,6 +32,7 @@ import {
3032
getLastSolvedTimeMap,
3133
getMaximumExcludeElapsedSecond,
3234
} from "../utils/LastSolvedTime";
35+
import { classifyContest } from "../utils/ContestClassifier";
3336
import { isProblemModelWithDifficultyModel } from "../interfaces/ProblemModel";
3437

3538
interface Props {
@@ -107,6 +110,7 @@ export const ProblemSetGenerator: React.FC<Props> = (props) => {
107110
useMultipleUserSubmissions(props.expectedParticipantUserIds).data ?? [];
108111
const alreadySolvedProblemIds = new Set(submissions.map((s) => s.problem_id));
109112
const lastSolvedTimeMap = getLastSolvedTimeMap(submissions);
113+
const { data: contests } = useContests();
110114

111115
const contestTypeKeyToDisplayName = (key: string) => {
112116
if (key.includes("Like")) {
@@ -323,6 +327,26 @@ export const ProblemSetGenerator: React.FC<Props> = (props) => {
323327
});
324328
}
325329

330+
let candidateContests: Contest[] = [];
331+
Object.keys(contestTypeOption).forEach((contestType) => {
332+
if (contestTypeOption[contestType]) {
333+
const filteredContests = contests.filter((contest) => {
334+
return (
335+
contestTypeKeyToDisplayName(contestType) ===
336+
classifyContest(contest)
337+
);
338+
});
339+
candidateContests = candidateContests.concat(
340+
filteredContests
341+
);
342+
}
343+
});
344+
candidateProblems = candidateProblems.filter((p) => {
345+
return candidateContests
346+
.map((contest) => contest.id)
347+
.includes(p.problem.contest_id);
348+
});
349+
326350
candidateProblems = candidateProblems.filter((p) => {
327351
if (excludeOption === "Exclude submitted") {
328352
return !alreadySolvedProblemIds.has(p.problem.id);

0 commit comments

Comments
 (0)