blob: 6ee5ae01f8c3653eab728023dda3e906230f3c38 (
plain)
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
|
package gitlab
import (
"fmt"
"github.com/xlgmokha/x/pkg/x"
)
type Group struct {
api *GitLab
id int
url string
}
func NewGroup(gl *GitLab, id int) *Group {
return &Group{
api: gl,
id: id,
url: fmt.Sprintf("%v/groups/%v", gl.url, id),
}
}
func (group *Group) EachIssue(fn func(*Issue)) {
page := "1"
perPage := "100"
for page != "" {
response := group.api.Get(fmt.Sprintf("%v/issues?page=%v&per_page=%v", group.url, page, perPage))
defer response.Body.Close()
for _, issue := range x.Must(FromIssues(response.Body)) {
go fn(&issue)
}
page = response.Header.Get("x-next-page")
perPage = response.Header.Get("x-per-page")
}
}
|