hpi-epic / repositoryguide

Guiding you in exploring your team's Git(Hub) repository
MIT License
1 stars 1 forks source link

How many comments/interactions (added labels, assignees) did a pr receive? #62

Closed SanJSp closed 3 years ago

SanJSp commented 3 years ago

As a Scrum coach, I'd like to see how many interactions pull requests receive in total.

Basically, PR closing times metric only with interactions as values. The question here is: What counts as interaction, and how is it trackable?

What can we track? What do the APIs return?

SanJSp commented 3 years ago

This GraphQL query currently returns the comments, the reviews and interactions regarding pull requests. The problem is the huge amount of pagination necessary and that I'm currently not able to grab the small interactions like these: grafik


query detailedPullRequests{
  repository(owner: "hpi-swt2", name: "connections-portal") {
    pullRequests(first: 1, after: "Y3Vyc29yOnYyOpHOIQnUng==") {
      pageInfo {
        hasNextPage
      }
      edges {
        cursor
        node {
          url
          author {
            login
          }
          reactions(first: 100){
            nodes{
              id         
            }
          }

          comments(first: 100) {
            nodes {
              body
              createdAt
              author {
                login
              }
            }
          }
          reviews(first: 100) {
            nodes {
              state
              createdAt
              body
              comments(first: 100) {
                nodes {
                  body
                }
              }
            }
          }
        }
      }
    }
  }
}
SanJSp commented 3 years ago

Label assignments do not seem possible, as there is no way to get the "assigned at" query. Your only able to check the updated_at and created_at field of a label.

SanJSp commented 3 years ago

Found a way to find these "interacting items". By using the timeLineItems nodes in he GraphQL query, we can find out the type of these interactions on the timeline. This allows to filter all reaction/team-based events and count them. The following problem is therefore solved:

....that I'm currently not able to grab the small interactions like these: grafik

SanJSp commented 3 years ago

So it is not completely possible to count the interactions based only on the timelineEvents, as there a review is only counted as one comment. I prefer counting every comment by the author and others, every review as one interaction, every review comment as one interaction, every emoji interaction as an interaction and every timelineEvent of certain types listed below. But should I also count the reactions to comments? For example, if a user reacts to a PR review with a thumbs up?

Relevant timelineEvents:

Current Query


query detailedPullRequests{
  repository(owner: "hpi-swt2", name: "connections-portal") {
    pullRequests(first: 1, after: "Y3Vyc29yOnYyOpHOIQnUng==") {
      pageInfo {
        hasNextPage
      }
      edges {
        cursor
        node {
          url
          author {
            login
          }
          reactions(first: 10){
            nodes{
              id         
            }
          }
    timelineItems(first: 100){
            nodes{
              __typename
            }
          }
          comments(first: 30) {
            nodes {
              body
              createdAt
              author {
                login
              }
            }
          }
          reviews(first: 4) {
            nodes {
              state
              createdAt
              body
              comments(first: 100) {
                nodes {
                  body
                }
              }
            }
          }
        }
      }
    }
  }
}
SanJSp commented 3 years ago

For simplicity’s sake, I'd prefer not to include the reactions on comments. That will become too much to process 😬

This was my current query until I've noticed a problem. The plan was to use pagination for f.e. the review comments so that we will simply paginate on the next comment-page of the pull request if there are too many. But this would create a huuuuge overhead as this would need a new query for each PR that needs pagination because this query can only deliver the next 100 PRs and not the next page of comments for only one PR. Without individual queries and pagination, this leads to fixed upper boundaries on the request, as we can only request a maximum of 500k nodes (and max 100 of each field - f.e. comments). With this in mind, does this metric still make sense? We could show everything to a scale of a "normal" PR, including up to 10 reviews and 100 comments each, 10 reactions, 30 comments and 100 timeline events per Pull Request.

Old query


query detailedPullRequests{
  repository(owner: "hpi-swt2", name: "connections-portal") {
    pullRequests(first: 100) {
      pageInfo {
        hasNextPage
      }
      edges {
        cursor
        node {
          url
          author {
            login
          }
          reactions(first: 10){
            nodes{
              id         
            }
            pageInfo{
              hasNextPage
            }
          }
    timelineItems(first: 100){
            nodes{
              __typename
            }
            pageInfo{
              hasNextPage
            }
          }
          comments(first: 30) {
            nodes {
              body
              createdAt
              author {
                login
              }
            }            
            pageInfo{
              hasNextPage
            }
          }
          reviews(first: 4) {
            nodes {
              state
              createdAt
              body
              comments(first: 100) {
                nodes {
                  body
                }
              }
            }
            pageInfo{
              hasNextPage
            }
          }
        }
      }
    }
  }
}

Query without pagination and fixed maxima


query detailedPullRequests{
  repository(owner: "hpi-swt2", name: "connections-portal") {
    pullRequests(first: 100) {
      pageInfo {
        hasNextPage
      }
      edges {
        cursor
        node {
          url
          author {
            login
          }
          reactions(first: 10){
            nodes{
              id         
            }
          }
    timelineItems(first: 100){
            nodes{
              __typename
            }
          }
          comments(first: 30) {
            nodes {
              body
              createdAt
              author {
                login
              }
            }
          }
          reviews(first: 10) {
            nodes {
              state
              createdAt
              body
              comments(first: 100) {
                nodes {
                  body
                }
              }
            }
          }
        }
      }
    }
  }
}