@@ -319,18 +319,6 @@ func (g *GithubDownloaderV3) GetReleases() ([]*base.Release, error) {
319
319
return releases , nil
320
320
}
321
321
322
- func convertGithubReactions (reactions * github.Reactions ) * base.Reactions {
323
- return & base.Reactions {
324
- TotalCount : * reactions .TotalCount ,
325
- PlusOne : * reactions .PlusOne ,
326
- MinusOne : * reactions .MinusOne ,
327
- Laugh : * reactions .Laugh ,
328
- Confused : * reactions .Confused ,
329
- Heart : * reactions .Heart ,
330
- Hooray : * reactions .Hooray ,
331
- }
332
- }
333
-
334
322
// GetIssues returns issues according start and limit
335
323
func (g * GithubDownloaderV3 ) GetIssues (page , perPage int ) ([]* base.Issue , bool , error ) {
336
324
opt := & github.IssueListByRepoOptions {
@@ -366,15 +354,34 @@ func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool,
366
354
for _ , l := range issue .Labels {
367
355
labels = append (labels , convertGithubLabel (& l ))
368
356
}
369
- var reactions * base.Reactions
370
- if issue .Reactions != nil {
371
- reactions = convertGithubReactions (issue .Reactions )
372
- }
373
357
374
358
var email string
375
359
if issue .User .Email != nil {
376
360
email = * issue .User .Email
377
361
}
362
+
363
+ // get reactions
364
+ var reactions []* base.Reaction
365
+ for i := 0 ; ; i ++ {
366
+ res , _ , err := g .client .Reactions .ListIssueReactions (g .ctx , g .repoOwner , g .repoName , issue .GetNumber (), & github.ListOptions {
367
+ Page : i ,
368
+ PerPage : perPage ,
369
+ })
370
+ if err != nil {
371
+ return nil , false , err
372
+ }
373
+ if len (res ) == 0 {
374
+ break
375
+ }
376
+ for _ , reaction := range res {
377
+ reactions = append (reactions , & base.Reaction {
378
+ UserID : reaction .User .GetID (),
379
+ UserName : reaction .User .GetLogin (),
380
+ Content : reaction .GetContent (),
381
+ })
382
+ }
383
+ }
384
+
378
385
allIssues = append (allIssues , & base.Issue {
379
386
Title : * issue .Title ,
380
387
Number : int64 (* issue .Number ),
@@ -418,9 +425,27 @@ func (g *GithubDownloaderV3) GetComments(issueNumber int64) ([]*base.Comment, er
418
425
if comment .User .Email != nil {
419
426
email = * comment .User .Email
420
427
}
421
- var reactions * base.Reactions
422
- if comment .Reactions != nil {
423
- reactions = convertGithubReactions (comment .Reactions )
428
+
429
+ // get reactions
430
+ var reactions []* base.Reaction
431
+ for i := 0 ; ; i ++ {
432
+ res , _ , err := g .client .Reactions .ListIssueCommentReactions (g .ctx , g .repoOwner , g .repoName , comment .GetID (), & github.ListOptions {
433
+ Page : i ,
434
+ PerPage : 100 ,
435
+ })
436
+ if err != nil {
437
+ return nil , err
438
+ }
439
+ if len (res ) == 0 {
440
+ break
441
+ }
442
+ for _ , reaction := range res {
443
+ reactions = append (reactions , & base.Reaction {
444
+ UserID : reaction .User .GetID (),
445
+ UserName : reaction .User .GetLogin (),
446
+ Content : reaction .GetContent (),
447
+ })
448
+ }
424
449
}
425
450
allComments = append (allComments , & base.Comment {
426
451
IssueIndex : issueNumber ,
@@ -473,8 +498,6 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
473
498
labels = append (labels , convertGithubLabel (l ))
474
499
}
475
500
476
- // FIXME: This API missing reactions, we may need another extra request to get reactions
477
-
478
501
var email string
479
502
if pr .User .Email != nil {
480
503
email = * pr .User .Email
@@ -515,6 +538,28 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
515
538
headUserName = * pr .Head .User .Login
516
539
}
517
540
541
+ // get reactions
542
+ var reactions []* base.Reaction
543
+ for i := 0 ; ; i ++ {
544
+ res , _ , err := g .client .Reactions .ListIssueReactions (g .ctx , g .repoOwner , g .repoName , pr .GetNumber (), & github.ListOptions {
545
+ Page : i ,
546
+ PerPage : perPage ,
547
+ })
548
+ if err != nil {
549
+ return nil , err
550
+ }
551
+ if len (res ) == 0 {
552
+ break
553
+ }
554
+ for _ , reaction := range res {
555
+ reactions = append (reactions , & base.Reaction {
556
+ UserID : reaction .User .GetID (),
557
+ UserName : reaction .User .GetLogin (),
558
+ Content : reaction .GetContent (),
559
+ })
560
+ }
561
+ }
562
+
518
563
allPRs = append (allPRs , & base.PullRequest {
519
564
Title : * pr .Title ,
520
565
Number : int64 (* pr .Number ),
@@ -545,7 +590,8 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
545
590
RepoName : * pr .Base .Repo .Name ,
546
591
OwnerName : * pr .Base .User .Login ,
547
592
},
548
- PatchURL : * pr .PatchURL ,
593
+ PatchURL : * pr .PatchURL ,
594
+ Reactions : reactions ,
549
595
})
550
596
}
551
597
0 commit comments