Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ebba4ab

Browse filesBrowse files
committed
add Assert
1 parent 8b81e5c commit ebba4ab
Copy full SHA for ebba4ab

File tree

Expand file treeCollapse file tree

5 files changed

+21
-1
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+21
-1
lines changed

‎pkg/collector/collector.go

Copy file name to clipboardExpand all lines: pkg/collector/collector.go
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"github.com/realzhangm/leetcode_collector/pkg/doa"
78
"os"
89
"path"
910
"strconv"
@@ -79,6 +80,9 @@ func (c *Collector) fetchAcProblemsDetail() error {
7980
if ee != nil {
8081
return ee
8182
}
83+
84+
doa.Assert(len(q.Question.Content) > 0)
85+
8286
mu.Lock()
8387
tmpMap[slug] = &q.Question
8488
mu.Unlock()
@@ -170,6 +174,7 @@ func (c *Collector) fetchOneSubmissions(slug string) error {
170174
return e
171175
}
172176

177+
// 每种语言选择最后的 accepted 的提交
173178
langSubmissionMap := c.submissionForOneLang(sbs.SubmissionList.Submissions)
174179
for _, sb := range langSubmissionMap {
175180
id, e2 := strconv.ParseInt(sb.ID, 10, 64)

‎pkg/collector/leetcode_cli/client.go

Copy file name to clipboardExpand all lines: pkg/collector/leetcode_cli/client.go
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8+
"github.com/realzhangm/leetcode_collector/pkg/doa"
89
"io"
910
"log"
1011
"net"
@@ -338,6 +339,7 @@ func (c *Client) QueryQuestionDetail(questionSlug string) (error, *QuestionDetai
338339
if err != nil {
339340
return errors.Wrap(ErrorClientGraphQl, err.Error()), nil
340341
}
342+
doa.Assert(r != nil)
341343
return nil, r
342344
}
343345

‎pkg/collector/model/main_markdown.go

Copy file name to clipboardExpand all lines: pkg/collector/model/main_markdown.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package model
22

33
import (
44
"fmt"
5+
"github.com/realzhangm/leetcode_collector/pkg/doa"
56
"os"
67
"sort"
78
"strconv"
@@ -158,6 +159,9 @@ func (p *PersonInfoNode) summaryTable() string {
158159
if !e {
159160
panic("not exist ?")
160161
}
162+
163+
doa.Assert(len(pd.TranslatedTitle) > 0)
164+
161165
tlf := TableLineFormat{
162166
slug: slug,
163167
ps: &ps,

‎pkg/collector/model/person_info_node.go

Copy file name to clipboardExpand all lines: pkg/collector/model/person_info_node.go
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ func (p *PersonInfoNode) DeleteAcSetAcSubmission(slug string) {
7474
func (p *PersonInfoNode) ProblemsDetailExist(slug string) bool {
7575
var exist bool
7676
p.Lock()
77-
_, exist = p.AcProblemsDetail[slug]
77+
detail, exist := p.AcProblemsDetail[slug]
78+
if len(detail.Content) == 0 || len(detail.TranslatedTitle) == 0 {
79+
exist = false
80+
}
7881
p.Unlock()
7982
return exist
8083
}

‎pkg/doa/doa.go

Copy file name to clipboardExpand all lines: pkg/doa/doa.go
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ func MustOK(err error) {
55
panic(err)
66
}
77
}
8+
9+
func Assert(ok bool) {
10+
if !ok {
11+
panic("")
12+
}
13+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.