Skip to content

Add: graphQLCnUrl #590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/leetcode/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (

func graphQLRequest(filename string, days int, jsonStr string, v interface{}) {
data := remember(filename, days, func() []byte {
return client.PostJson(graphqlUrl, jsonStr)
return client.PostJson(graphQL, jsonStr)
})
jsonDecode(data, &v)
}
Expand Down
5 changes: 4 additions & 1 deletion internal/leetcode/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const (
apiProblemsShellUrl = "https://leetcode.com/api/problems/shell/"
problemsetAllUrl = "https://leetcode.com/problemset/all/"
questionArticleUrl = "https://leetcode.com/articles/%s/"
graphqlUrl = "https://leetcode-cn.com/graphql"
graphQLUrl = "https://leetcode.com/graphql"
graphQLCnUrl = "https://leetcode-cn.com/graphql"
apiProgressAllUrl = "https://leetcode.com/api/progress/all/"
submissionsLatestUrl = "https://leetcode.com/submissions/latest/"
)
Expand All @@ -26,3 +27,5 @@ const (
questionArticleFile = "question_article_%s.html"
topicTagFile = "topic_tag_%s.json"
)

var graphQL = graphQLCnUrl
5 changes: 5 additions & 0 deletions internal/leetcode/question_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ func QuestionData(titleSlug string, isForce bool) (qd questionDataType) {
graphQLRequest(filename, days, jsonStr, &qd)
if qd.Data.Question.TitleSlug == "" {
_ = os.Remove(getCachePath(filename))
if graphQL == graphQLCnUrl {
graphQL = graphQLUrl
return QuestionData(titleSlug, isForce)
}
for _, err := range qd.Errors {
log.Println(titleSlug, err.Message)
}
}
graphQL = graphQLCnUrl
return
}

Expand Down
2 changes: 1 addition & 1 deletion tag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
| 11 | [Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md) | [广度优先搜索](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md) | | 12 | [Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md) | [栈](https://github.com/openset/leetcode/tree/master/tag/stack/README.md) |
| 13 | [Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md) | [回溯算法](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md) | | 14 | [Design](https://github.com/openset/leetcode/tree/master/tag/design/README.md) | [设计](https://github.com/openset/leetcode/tree/master/tag/design/README.md) |
| 15 | [Linked List](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md) | [链表](https://github.com/openset/leetcode/tree/master/tag/linked-list/README.md) | | 16 | [Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md) | [堆](https://github.com/openset/leetcode/tree/master/tag/heap/README.md) |
| 17 | [Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md) | [位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md) | | 18 | [Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md) | [排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md) |
| 17 | [Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md) | [排序](https://github.com/openset/leetcode/tree/master/tag/sort/README.md) | | 18 | [Bit Manipulation](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md) | [位运算](https://github.com/openset/leetcode/tree/master/tag/bit-manipulation/README.md) |
| 19 | [Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md) | [图](https://github.com/openset/leetcode/tree/master/tag/graph/README.md) | | 20 | [Union Find](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md) | [并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md) |
| 21 | [Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md) | [分治算法](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md) | | 22 | [Trie](https://github.com/openset/leetcode/tree/master/tag/trie/README.md) | [字典树](https://github.com/openset/leetcode/tree/master/tag/trie/README.md) |
| 23 | [Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md) | [Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md) | | 24 | [Recursion](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md) | [递归](https://github.com/openset/leetcode/tree/master/tag/recursion/README.md) |
Expand Down
1 change: 1 addition & 0 deletions tag/depth-first-search/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

| # | 题名 | 标签 | 难度 |
| :-: | - | - | :-: |
| 1080 | [根到叶路径上的不足节点](https://github.com/openset/leetcode/tree/master/problems/insufficient-nodes-in-root-to-leaf-paths) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium |
| 1061 | [按字典序排列最小的等效字符串](https://github.com/openset/leetcode/tree/master/problems/lexicographically-smallest-equivalent-string) 🔒 | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] [[并查集](https://github.com/openset/leetcode/tree/master/tag/union-find/README.md)] | Medium |
| 1034 | [边框着色](https://github.com/openset/leetcode/tree/master/problems/coloring-a-border) | [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Medium |
| 1028 | [从先序遍历还原二叉树](https://github.com/openset/leetcode/tree/master/problems/recover-a-tree-from-preorder-traversal) | [[树](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)] [[深度优先搜索](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)] | Hard |
Expand Down
10 changes: 5 additions & 5 deletions tag/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@
"Slug": "heap",
"TranslatedName": "堆"
},
{
"Name": "Bit Manipulation",
"Slug": "bit-manipulation",
"TranslatedName": "位运算"
},
{
"Name": "Sort",
"Slug": "sort",
"TranslatedName": "排序"
},
{
"Name": "Bit Manipulation",
"Slug": "bit-manipulation",
"TranslatedName": "位运算"
},
{
"Name": "Graph",
"Slug": "graph",
Expand Down