From c74eae8a6a950a1f79390b217d1237dd8818c2d9 Mon Sep 17 00:00:00 2001 From: openset Date: Mon, 20 May 2019 11:14:24 +0800 Subject: [PATCH] Add: v1.3.0 --- internal/leetcode/question_translation.go | 12 +++++++++++- internal/leetcode/topic_tag.go | 10 +++++++++- internal/version/version.go | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/internal/leetcode/question_translation.go b/internal/leetcode/question_translation.go index 8fd546b86..98a2edba1 100644 --- a/internal/leetcode/question_translation.go +++ b/internal/leetcode/question_translation.go @@ -1,6 +1,10 @@ package leetcode -import "strconv" +import ( + "log" + "os" + "strconv" +) func GetQuestionTranslation() (qt questionTranslationType) { jsonStr := `{ @@ -9,6 +13,12 @@ func GetQuestionTranslation() (qt questionTranslationType) { "query": "query getQuestionTranslation($lang: String) {\n translations: allAppliedQuestionTranslations(lang: $lang) {\n title\n question {\n questionId\n __typename\n }\n __typename\n }\n}\n" }` graphQLRequest(questionTranslationFile, 2, jsonStr, &qt) + if qt.Data.Translations == nil { + _ = os.Remove(getCachePath(questionTranslationFile)) + for _, err := range qt.Errors { + log.Println(err.Message) + } + } return } diff --git a/internal/leetcode/topic_tag.go b/internal/leetcode/topic_tag.go index 0048a048b..3f263671d 100644 --- a/internal/leetcode/topic_tag.go +++ b/internal/leetcode/topic_tag.go @@ -3,6 +3,8 @@ package leetcode import ( "bytes" "fmt" + "log" + "os" "path" "regexp" "sort" @@ -69,10 +71,16 @@ func GetTopicTag(slug string) (tt topicTagType) { "variables": { "slug": "` + slug + `" }, - "query": "query getTopicTag($slug: String!) {\n topicTag(slug: $slug) {\n name\n translatedName\n questions {\n status\n questionId\n questionFrontendId\n title\n titleSlug\n translatedTitle\n stats\n difficulty\n isPaidOnly\n topicTags {\n name\n translatedName\n slug\n __typename\n }\n companyTags {\n name\n translatedName\n slug\n __typename\n }\n __typename\n }\n frequencies\n __typename\n }\n favoritesLists {\n publicFavorites {\n ...favoriteFields\n __typename\n }\n privateFavorites {\n ...favoriteFields\n __typename\n }\n __typename\n }\n}\n\nfragment favoriteFields on FavoriteNode {\n idHash\n id\n name\n isPublicFavorite\n viewCount\n creator\n isWatched\n questions {\n questionId\n title\n titleSlug\n __typename\n }\n __typename\n}\n" + "query": "query getTopicTag($slug: String!) {\n topicTag(slug: $slug) {\n name\n translatedName\n questions {\n status\n questionId\n questionFrontendId\n title\n titleSlug\n translatedTitle\n stats\n difficulty\n isPaidOnly\n topicTags {\n name\n translatedName\n slug\n __typename\n }\n __typename\n }\n frequencies\n __typename\n }\n favoritesLists {\n publicFavorites {\n ...favoriteFields\n __typename\n }\n privateFavorites {\n ...favoriteFields\n __typename\n }\n __typename\n }\n}\n\nfragment favoriteFields on FavoriteNode {\n idHash\n id\n name\n isPublicFavorite\n viewCount\n creator\n isWatched\n questions {\n questionId\n title\n titleSlug\n __typename\n }\n __typename\n}\n" }` filename := fmt.Sprintf(topicTagFile, slugToSnake(slug)) graphQLRequest(filename, 2, jsonStr, &tt) + if tt.Data.TopicTag.Name == "" { + _ = os.Remove(getCachePath(filename)) + for _, err := range tt.Errors { + log.Println(slug, err.Message) + } + } return } diff --git a/internal/version/version.go b/internal/version/version.go index 169487c00..9f2b10b4d 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -7,7 +7,7 @@ import ( "github.com/openset/leetcode/internal/base" ) -const version = "1.2.0" +const version = "1.3.0" var CmdVersion = &base.Command{ Run: runVersion,