Skip to content
This repository has been archived by the owner on Aug 2, 2018. It is now read-only.

Commit

Permalink
fix merge bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li committed Jan 22, 2018
1 parent 50d4203 commit fd342b3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions cmd/question_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ func main() {
brain.MergeQuestions(files...)
} else if source == "issue" {
doc, _ := goquery.NewDocument(issueUrl)
doc.Find("div.comment").Each(func(index int, comment *goquery.Selection) {
doc.Find("div.timeline-comment-wrapper").Each(func(index int, comment *goquery.Selection) {
author := comment.Find("a.author").Text()
comment.Find("td.d-block p a").Each(func(i int, s *goquery.Selection) {
if strings.Contains(s.Text(), ".zip") {
href, _ := s.Attr("href")
if href != "" {
err := handleZipUrl(href)
err := handleZipUrl(author, href)
if err != nil {
log.Println("Error", err.Error())
}
Expand All @@ -63,8 +64,8 @@ func main() {
log.Println("total questions =>", total)
}

func handleZipUrl(url string) error {
println("handling", url)
func handleZipUrl(author, url string) error {
println("handling", author, url)
var exist bool
memoryDb.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte(QuestionUrlBucket))
Expand Down
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ func MergeQuestions(fs ...string) {
var i int
for _, f := range fs {
thirdDb, err := bolt.Open(f, 0600, nil)
defer thirdDb.Close()
if err != nil {
log.Println("error in merge file db "+f, err.Error())
continue
}
defer thirdDb.Close()
thirdDb.View(func(thirdTx *bolt.Tx) error {
// Assume bucket exists and has keys
b := thirdTx.Bucket([]byte(QuestionBucket))
Expand Down
Binary file modified merge.data
Binary file not shown.
Binary file modified questions.data
Binary file not shown.

0 comments on commit fd342b3

Please sign in to comment.