Skip to content

Commit 95bd4e7

Browse files
committed
Query which dates a LeetCode problem was the problem of the day
1 parent 5924349 commit 95bd4e7

File tree

6 files changed

+3360
-3336
lines changed

6 files changed

+3360
-3336
lines changed

workspaces/archive/problems.jsonl

Lines changed: 3312 additions & 3312 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workspaces/leetcode-api/src/api/question-list/fetchGraphQL.generated.ts

Lines changed: 24 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workspaces/leetcode-api/src/api/question-list/main.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
import { z } from "zod";
22

3+
import { compareStringsCaseInsensitive } from "@code-chronicles/util/compareStringsCaseInsensitive";
34
import { numericIdAsNumberZodType } from "@code-chronicles/util/numericIdAsNumberZodType";
45

56
import { fetchGraphQL, type QueryVariables } from "./fetchGraphQL.generated.ts";
67
import { questionDifficultyZodType } from "../../zod-types/questionDifficultyZodType.ts";
78
import { questionTitleSlugZodType } from "../../zod-types/questionTitleSlugZodType.ts";
89

9-
const questionZodType = z.object({
10-
difficulty: questionDifficultyZodType,
11-
isPaidOnly: z.boolean(),
12-
questionFrontendId: numericIdAsNumberZodType,
13-
title: z.string().trim().min(1),
14-
titleSlug: questionTitleSlugZodType,
15-
});
10+
const questionZodType = z
11+
.object({
12+
challengeQuestionsV2: z
13+
.array(z.object({ date: z.string() }).transform(({ date }) => date))
14+
.transform((dates) =>
15+
[...dates].sort(compareStringsCaseInsensitive).reverse(),
16+
),
17+
difficulty: questionDifficultyZodType,
18+
isPaidOnly: z.boolean(),
19+
questionFrontendId: numericIdAsNumberZodType,
20+
title: z.string().trim().min(1),
21+
titleSlug: questionTitleSlugZodType,
22+
})
23+
.transform(({ challengeQuestionsV2, ...rest }) => ({
24+
chalengeQuestionDates: challengeQuestionsV2,
25+
...rest,
26+
}));
1627

1728
export type QuestionListQuestion = z.infer<typeof questionZodType>;
1829

workspaces/leetcode-api/src/api/question-list/query.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ query QuestionList(
1111
filters: $filters
1212
) {
1313
data {
14+
challengeQuestionsV2 {
15+
date
16+
}
1417
difficulty
1518
isPaidOnly
1619
questionFrontendId

workspaces/leetcode-api/src/api/question-list/queryTypes.generated.ts

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workspaces/leetcode-api/src/graphqlTypes.generated.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)