| 25 | } |
| 26 | |
| 27 | function getCNProblemStats( |
| 28 | difficulty: string, |
| 29 | progress: Record<string, ProblemCount[]>, |
| 30 | ): DifficultyStats { |
| 31 | return { |
| 32 | solved: progress.ac.find((x) => x.difficulty === difficulty.toUpperCase())?.count || 0, |
| 33 | total: (Object.values(progress) as ProblemCount[][]).reduce( |
| 34 | (acc, arr) => |
| 35 | acc + (arr.find((x) => x.difficulty === difficulty.toUpperCase())?.count || 0), |
| 36 | 0, |
| 37 | ), |
| 38 | }; |
| 39 | } |
| 40 | |
| 41 | export class Query { |
| 42 | async us(username: string, headers?: Record<string, string>): Promise<FetchedData> { |