Skip to content

Commit 821343a

Browse files
authored
Query which dates a LeetCode problem was the problem of the day (#458)
This seems like it would be useful data to track!
1 parent d7cd59e commit 821343a

File tree

7 files changed

+3357
-3325
lines changed

7 files changed

+3357
-3325
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/graphql-codegen.config.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,30 @@ const commonTypeScriptPluginConfig: GraphQLCodegen.PluginConfig = {
1111
skipTypename: true,
1212
useTypeImports: true,
1313

14+
strictScalars: true,
1415
scalars: {
16+
Date: {
17+
input: "unknown",
18+
output: "string",
19+
},
1520
DateTime: {
1621
input: "unknown",
1722
output: "string",
1823
},
24+
Decimal: {
25+
input: "unknown",
26+
// For example: "4.816"
27+
output: "string",
28+
},
1929
JSONString: {
2030
input: "unknown",
2131
output: "string",
2232
},
33+
UUID: {
34+
input: "string",
35+
output: "string",
36+
},
2337
},
24-
25-
// TODO: add strictScalars: true
2638
};
2739

2840
const headerPlugin: GraphQLCodegen.OutputConfig = {

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

Lines changed: 6 additions & 1 deletion
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: 1 addition & 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: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)