aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/gitlab/iterator/labelEvent.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-04-04 11:59:53 +0200
committerMichael Muré <batolettre@gmail.com>2020-04-04 12:42:08 +0200
commit903549cadf40ede3771053781eb6e9fd31aaa64e (patch)
tree58df795ebf4bc2f5517c2537135bef2bb2a77c10 /bridge/gitlab/iterator/labelEvent.go
parentf4ca533fe10f7fa893e1953f8c8d9ed3e783486c (diff)
downloadgit-bug-903549cadf40ede3771053781eb6e9fd31aaa64e.tar.gz
gitlab: fix iterator (paginate with first index 1) and avoid the trailing API call
Diffstat (limited to 'bridge/gitlab/iterator/labelEvent.go')
-rw-r--r--bridge/gitlab/iterator/labelEvent.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/bridge/gitlab/iterator/labelEvent.go b/bridge/gitlab/iterator/labelEvent.go
index 7ee2604b..812e6646 100644
--- a/bridge/gitlab/iterator/labelEvent.go
+++ b/bridge/gitlab/iterator/labelEvent.go
@@ -49,7 +49,7 @@ func (lei *labelEventIterator) getNext(ctx context.Context, conf config) (bool,
// and sort them by ID
page := 1
for {
- labelEvents, _, err := conf.gc.ResourceLabelEvents.ListIssueLabelEvents(
+ labelEvents, resp, err := conf.gc.ResourceLabelEvents.ListIssueLabelEvents(
conf.project,
lei.issue,
&gitlab.ListLabelEventsOptions{
@@ -68,7 +68,13 @@ func (lei *labelEventIterator) getNext(ctx context.Context, conf config) (bool,
if len(labelEvents) == 0 {
break
}
+
lei.cache = append(lei.cache, labelEvents...)
+
+ if resp.TotalPages == page {
+ break
+ }
+
page++
}