@@ -319,18 +319,6 @@ func (g *GithubDownloaderV3) GetReleases() ([]*base.Release, error) {
319319 return releases , nil
320320}
321321
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-
334322// GetIssues returns issues according start and limit
335323func (g * GithubDownloaderV3 ) GetIssues (page , perPage int ) ([]* base.Issue , bool , error ) {
336324 opt := & github.IssueListByRepoOptions {
@@ -366,15 +354,34 @@ func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool,
366354 for _ , l := range issue .Labels {
367355 labels = append (labels , convertGithubLabel (& l ))
368356 }
369- var reactions * base.Reactions
370- if issue .Reactions != nil {
371- reactions = convertGithubReactions (issue .Reactions )
372- }
373357
374358 var email string
375359 if issue .User .Email != nil {
376360 email = * issue .User .Email
377361 }
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+
378385 allIssues = append (allIssues , & base.Issue {
379386 Title : * issue .Title ,
380387 Number : int64 (* issue .Number ),
@@ -418,9 +425,27 @@ func (g *GithubDownloaderV3) GetComments(issueNumber int64) ([]*base.Comment, er
418425 if comment .User .Email != nil {
419426 email = * comment .User .Email
420427 }
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+ }
424449 }
425450 allComments = append (allComments , & base.Comment {
426451 IssueIndex : issueNumber ,
@@ -473,8 +498,6 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
473498 labels = append (labels , convertGithubLabel (l ))
474499 }
475500
476- // FIXME: This API missing reactions, we may need another extra request to get reactions
477-
478501 var email string
479502 if pr .User .Email != nil {
480503 email = * pr .User .Email
@@ -515,6 +538,28 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
515538 headUserName = * pr .Head .User .Login
516539 }
517540
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+
518563 allPRs = append (allPRs , & base.PullRequest {
519564 Title : * pr .Title ,
520565 Number : int64 (* pr .Number ),
@@ -545,7 +590,8 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq
545590 RepoName : * pr .Base .Repo .Name ,
546591 OwnerName : * pr .Base .User .Login ,
547592 },
548- PatchURL : * pr .PatchURL ,
593+ PatchURL : * pr .PatchURL ,
594+ Reactions : reactions ,
549595 })
550596 }
551597
0 commit comments