Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 7d0eff5

Browse files
Handle pack size missings (#78)
* handle pack size missings Signed-off-by: Ayman <enkhalifapro@gmail.com> * test changes Signed-off-by: Ayman <enkhalifapro@gmail.com> * code clean up Signed-off-by: Ayman <enkhalifapro@gmail.com> --------- Signed-off-by: Ayman <enkhalifapro@gmail.com> Co-authored-by: Ayman <enkhalifapro@gmail.com>
1 parent 4891c46 commit 7d0eff5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cmd/github/github.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,7 +3400,7 @@ func (j *DSGitHub) FetchItemsPullRequest(ctx *shared.Ctx) (err error) {
34003400
count += len(pulls.Issues)
34013401
totalFetched += len(pulls.Issues)
34023402
pullrequests = append(pullrequests, pulls.Issues...)
3403-
if len(pullrequests) == 1000 || response.NextPage == 0 {
3403+
if len(pullrequests) == ctx.PackSize || response.NextPage == 0 {
34043404
for _, pull := range pullrequests {
34053405
pr := map[string]interface{}{}
34063406
jm, _ := jsoniter.Marshal(pull)
@@ -3432,19 +3432,23 @@ func (j *DSGitHub) FetchItemsPullRequest(ctx *shared.Ctx) (err error) {
34323432
j.log.WithFields(logrus.Fields{"operation": "FetchItemsPullRequest"}).Debugf("%d remaining pulls to send to queue", nPulls)
34333433
}
34343434

3435-
if count == 1000 {
3436-
j.log.WithFields(logrus.Fields{"operation": "FetchItemsActions"}).Infof("fetched %d pulls", totalFetched)
3435+
if count == ctx.PackSize {
3436+
j.log.WithFields(logrus.Fields{"operation": "FetchItemsPullRequest"}).Infof("fetched %d pulls", totalFetched)
34373437
dateFrom = updateAt
34383438
opt.Page = 1
34393439
count = 0
34403440
continue
34413441
}
34423442
if response.NextPage == 0 {
3443+
err = j.GitHubEnrichItems(ctx, allPulls, &allDocs, true)
3444+
if err != nil {
3445+
j.log.WithFields(logrus.Fields{"operation": "FetchItemsPullRequest"}).Errorf("%s/%s: error %v sending %d pulls to queue", j.URL, j.CurrentCategory, err, len(allPulls))
3446+
}
34433447
break
34443448
}
34453449
opt.Page = response.NextPage
34463450
}
3447-
j.log.WithFields(logrus.Fields{"operation": "FetchItemsActions"}).Infof("total count of fetched pulls: %d, fetched till: %v", totalFetched, latestUpdateAt)
3451+
j.log.WithFields(logrus.Fields{"operation": "FetchItemsPullRequest"}).Infof("total count of fetched pulls: %d, fetched till: %v", totalFetched, latestUpdateAt)
34483452

34493453
return
34503454
}
@@ -6098,6 +6102,9 @@ func (j *DSGitHub) Sync(ctx *shared.Ctx, category string) (err error) {
60986102
}
60996103
// NOTE: Non-generic ends here
61006104
err = j.setLastSync()
6105+
if err != nil {
6106+
return
6107+
}
61016108
j.log.WithFields(logrus.Fields{"operation": "SetLastSync"}).Info("Sync: last sync date has been updated successfully")
61026109

61036110
return

0 commit comments

Comments
 (0)