-
Notifications
You must be signed in to change notification settings - Fork 1
/
githubUser.go
50 lines (39 loc) · 996 Bytes
/
githubUser.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"log"
)
const (
NOTSTART = "NotStart"
FETCHING = "Fetching"
INDEXING = "Indexing"
INDEXED = "Indexed"
ERROR = "Error"
)
type GitHubUser struct {
Account string `json:"account"`
// AccessToken string `json:"accessToken"`
Tokens []string `json:"tokens"`
Status string `json:"status"`
NumOfStarred int
IndicesOfStarrerd int
}
func (user *GitHubUser) IndexStarredInfo(token string) {
user.Status = FETCHING
SetUser(user.Account, *user)
repoList, _ := GetStarredInfo(user.Account, token)
user.Status = INDEXING
len := len(repoList)
user.NumOfStarred = len
SetUser(user.Account, *user)
log.Println("get number of starred:", user.NumOfStarred)
// b, _ := json.Marshal(&repoList)
// fmt.Println("total repo:", string(b))
// try to indexing
err := SendToGitHubElasticsearch(repoList, user.Account)
fmt.Println("after send")
if err == nil {
user.Status = INDEXED
SetUser(user.Account, *user)
}
}