Skip to content

Proskynete/get-metrics-from-github

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Get Github PR Metrics

Nextjs With love PRs Welcome



Table of contents
  1. Prepare environment
  2. How to use

⚙️ Prepare environment

We need the following things:

  • Python
  • pytz
  • Create a personal access token in your Github account
  • Know the name of the organization: Example: Proskynete
  • Know the name of the repository you want to analyze. Example: vertical-timeline-component-react

🌟 Github Token

To get Github PR metrics, you need to create a personal access token. Follow the link below to learn how to create a personal access token

⌛️ Environment variable

Recommendation: If you want to optimize your time, you can add the following environment variables in your pc, so that the script only asks you for the name of the repository

export GITHUB_TOKEN=<your-token>
export GITHUB_ORGANIZATION=<the-organization-name>

In case you don't want to add environment variables, the script will always ask for your personal access token and organization name

💪 How to use

Run the following command:

  • With Python 2
python get_metrics.py
  • With Python 3
python3 get_metrics.py
  • Then, in the terminal you must write your personal access token (called GITHUB_TOKEN), the organization name (called GITHUB_ORGANIZATION), the repository name and finally the number of days with which you will obtain the metric (default will be 30 days).
❯ Enter your personal github access token:
❯ Enter the organization name or user name:
❯ Enter github repository name:
❯ Enter the number of days to extract data (if you write 0, it will default to 30):

If you previously added GITHUB_TOKEN and GITHUB_ORGANIZATION as environment variables, the terminal will only prompt you for the repository name and number days.

❯ Enter github repository name:
❯ Enter the number of days to extract data (if you write 0, it will default to 30):

Once you finish adding the requested information, the script will start scanning for the latest PRs found between today and the last x days (based on what you typed) and display the result as what you see below:

🏁 Start the extraction of data from the VERTICAL-TIMELINE-COMPONENT-REACT project of the last 240 days
💾 Extracting from page 1...
💾 Extracting from page 2...

--- ⌛️ Total execution time: 1.3048 seconds ⌛️ ---

        Average: 68 days
        Max: 204 days
        Min: 0 days
        Count: 3 PRs
        Contributors:
                - Proskynete has 1 PRs
                - jangoergens has 1 PRs
                - stevending1st has 1 PRs

👾 See you!

In case there are no PRs within the date range, what you will see will be the following

🏁 Start the extraction of data from the ADMIN project of the last 1 days

💩 There are not enough PRs to generate the report.
👾 Bye!