Skip to content

Commit

Permalink
fix: Reaction to our last comment is actionable
Browse files Browse the repository at this point in the history
  • Loading branch information
chelmertz committed Oct 10, 2024
1 parent 266ea49 commit 93e3432
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions internal/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ func userReactedToComment(reactions prReviewThreadCommentReactionGraphQl, userna
return false
}

func someoneElseReactedToComment(reactions prReviewThreadCommentReactionGraphQl, username string) bool {
for _, r := range reactions.Edges {
if r.Node.User.Login != username {
return true
}
}
return false
}

func actionableThreads(pr prSearchResultGraphQl, myUsername string) (actionable int, waiting int) {
ownPr := pr.Author.Login == myUsername
for _, t := range pr.ReviewThreads.Edges {
Expand All @@ -302,23 +311,32 @@ func actionableThreads(pr prSearchResultGraphQl, myUsername string) (actionable

lastComment := t.Node.Comments.Nodes[len(t.Node.Comments.Nodes)-1]
lastCommenter := lastComment.Author.Login
iCommentedLast := lastCommenter == myUsername
iReactedToLastComment := userReactedToComment(lastComment.Reactions, myUsername)
someoneElseReactedMyLastComment := iCommentedLast && someoneElseReactedToComment(lastComment.Reactions, myUsername)

if ownPr && lastCommenter != myUsername && !iReactedToLastComment {
if ownPr && !iCommentedLast && !iReactedToLastComment {
// someone else commented last, and this is our pr, and we haven't
// acknowledged it yet with a reaction (emoji)
actionable++
continue
}

if ownPr && someoneElseReactedMyLastComment {
// we commented last, and this is our pr, and they reacted to it
// (thumbs up etc.) acknowledged it yet
actionable++
continue
}

if !ownPr && lastCommenter == myUsername {
// we have the currently last word, the owner should reply or resolve the thread
waiting++
continue
}

threadStarter := t.Node.Comments.Nodes[0].Author.Login
if threadStarter == myUsername && lastCommenter != myUsername && !iReactedToLastComment {
if threadStarter == myUsername && !iCommentedLast && !iReactedToLastComment {
// we started the thread, and it's still open (and someone else has
// the last word), and we haven't acknowledged it yet with a
// reaction (emoji)
Expand Down
2 changes: 1 addition & 1 deletion internal/points/points.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func StandardPrPoints(pr types.ViewPr, username string) *Points {
}

if pr.ThreadsActionable > 0 {
points.Add(80, fmt.Sprintf("Someone asked us something (%d comments)", pr.ThreadsActionable))
points.Add(80, fmt.Sprintf("Someone asked us something, or reacted to our comment (%d comments)", pr.ThreadsActionable))
// we already need to go over this, don't scale the points
// by amount of threads though, it might go overboard
}
Expand Down

0 comments on commit 93e3432

Please sign in to comment.