-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissues.go
58 lines (46 loc) · 915 Bytes
/
issues.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
51
52
53
54
55
56
57
58
package ghsync
import (
"github.com/google/go-github/github"
"time"
)
func (s *Syncer) syncIssues() error {
last, err := s.data.LastUpdatedIssue()
if err != nil {
return err
}
var (
page = 1
size = 100
since time.Time
)
if last != nil {
since = *last.UpdatedAt
}
for {
issues, resp, err := s.client.Issues.ListByOrg(s.conf.Organization, &github.IssueListOptions{
Filter: "all",
State: "all",
Sort: "updated",
Direction: "asc",
Since: since,
ListOptions: github.ListOptions{
Page: page,
PerPage: size,
},
})
if err != nil {
return err
}
for i := range issues {
s.logger.Debug().Log("msg", "updating issue", "resp", *issues[i].Repository.Name, "issue", *issues[i].Number)
if err := s.data.UpdateIssue(&issues[i]); err != nil {
return err
}
}
if resp.NextPage == 0 {
break
}
page++
}
return nil
}