API guide: Unreviewed PRs by PR state

Tags: Flow

Overview

Unreviewed PRs are PRs that have 0 comments and 0 approvals. Pulling a list of unreviewed PRs can be done in one API call. This guide will show you how to export unreviewed PRs by state (open,closed,merged) via the API.

Merged or closed unreviewed PRs

Step 1: Grab all merged or closed PRs that have 0 comments

In this step you will grab all PRs that were merged or closed during a specific time frame.

https://HOSTNAME/v3/customer/core/pull_requests/?closed_at__gte=START_DATE&closed_at__lte=END_DATE&reviewer_comment_count=0&fields=id,title,number,state,created_by_id,reviewer_comment_count,approval_count
  • HOSTNAME: This is the IP address or URL for the Flow application. If you are using the cloud instance of Flow, this will be flow.pluralsight.com. If you’re using an on-premise version of Flow, this will be something other than flow.pluralsight.com.
  • START_DATE/END_DATE: Select your start and end dates. This API call is using “closed_at” so you will only be looking at PRs that were closed/merged during the selected dates.
  • Fields: This filter allows you to select which fields to include in your results. You can modify this based on your needs but this API call will show you
    • PR ID
    • PR Title
    • PR Number
    • State (merged or closed)
    • Created by ID – you can use this ID to locate the User name in the user_alias endpoint
    • Reviewer Comment Count – this should be 0
    • Approval count
Important: GitHub approvals are a type of comment, so when reviewer_comment_count=0 then approval_count should also be 0. For other Git hosts approvals are separate from the reviewer_comment_count so you can have a PR with 0 comments but 1 or more approvals.

Your results will look something like this:

<count>3</count>
<results>
<list-item>
   <id>123</id>
   <title>Configuration update</title>
   <number>3</number>
   <state>closed</state>
   <created_by_id>111112</created_by_id>
   <approval_count>0</approval_count>
   <reviewer_comment_count>0</reviewer_comment_count>
</list-item>
<list-item>
   <id>456</id>
   <title>Troubleshoot form</title>
   <number>627</number>
   <state>merged</state>
   <created_by_id>22345</created_by_id>
   <approval_count>0</approval_count>
   <reviewer_comment_count>0</reviewer_comment_count>
</list-item>
<list-item>
   <id>789</id>
   <title>Correcting string formatting</title>
   <number>278</number>
   <state>merged</state>
   <created_by_id>24789</created_by_id>
   <approval_count>4</approval_count>
   <reviewer_comment_count>0</reviewer_comment_count>
</list-item>

In the example above there are three PRs that have 0 comments and are merged or closed. One of the PRs does have approvals so we will exclude this PR from our total Unreviewed merged/closed PR count.

PR ID: 123 - 0 comments and 0 approvals = unreviewed

PR ID: 456 - 0 comments and 0 approvals = unreviewed

PR ID: 789 - 0 comments and 4 approvals = reviewed

Total merged/closed unreviewed PRs = 2

For GitHub hosted repositories, your unreviewed PR total will be the number you see next to <count>. If your repos are hosted on a Git host other than GitHub, you will need to export this data into a .csv file and remove any PRs that have 1 or more approvals as these PRs have been reviewed. You can export this data by appending format=csv to the end of your API call:


https://HOSTNAME/v3/customer/core/pull_requests/?closed_at__gte=START_DATE&closed_at__lte=END_DATE&reviewer_comment_count=0&fields=id,title,number,state,created_by_id,reviewer_comment_count,approval_count&format=csv

Open unreviewed PRs

To calculate the total number of unreviewed open PRs the initial API call changes slightly but the process is the same as above.

Step 1: Grab all open PRs that have 0 comments

In this step you will grab all PRs that were created and remain open during a specific time frame.


https://HOSTNAME/v3/customer/core/pull_requests/?created_at__gte=START_DATE&created_at__lte=END_DATE&state=open&reviewer_comment_count=0&fields=id,title,number,state,created_by_id,reviewer_comment_count,approval_count
  • HOSTNAME: This is the IP address or URL for the Flow application. If you are using the cloud instance of Flow, this will be flow.pluralsight.com. If you’re using an on-premise version of Flow, this will be something other than flow.pluralsight.com.
  • START_DATE/END_DATE: Select your start and end dates. This API call is using “created_at” so you will only be looking at PRs that were created during the selected dates.
  • State: This filter allows you to select what state (open,closed,merged) the PRs are in. In this example we are using "open" so all PRs in your results will be open.
  • Fields: This filter allows you to select which fields to include in your results. You can modify this based on your needs.

Your results will look something like this:

<root>
<count>2</count>
<results>
<list-item>
   <id>1012</id>
   <title>Disable for sandboxes</title>
   <number>100</number>
   <state>open</state>
   <created_by_id>3356</created_by_id>
   <approval_count>1</approval_count>
   <reviewer_comment_count>0</reviewer_comment_count>
</list-item>
<list-item>
   <id>1314</id>
   <title>Rearranged directory</title>
   <number>101</number>
   <state>open</state>
   <created_by_id>32303</created_by_id>
   <approval_count>0</approval_count>
   <reviewer_comment_count>0</reviewer_comment_count>
</list-item>

In the above example there are two open PRs that have 0 comments during the selected time period. One of the PRs does have an approval so our total unreviewed open PRs will be 1.

PR ID: 1012 - 0 comments and 1 approval = reviewed

PR ID: 1314 - 0 comments and 0 approvals = unreviewed

Total unreviewed open PRs = 1

Tip: Remember if your repos are not hosted with GitHub approvals will be tracked separately from comments so you will need to export your results and exclude any PR that has 1 or more approvals from your total.

back to top


If you need help, please email support@pluralsight.com for 24/7 assistance.