Skip to content

Latest commit

 

History

History
73 lines (51 loc) · 2.62 KB

File metadata and controls

73 lines (51 loc) · 2.62 KB

Find Inactive Organization Members

find_inactive_members.rb - Find and output inactive members in an organization
    -c, --check                      Check connectivity and scope
    -d, --date MANDATORY             Date from which to start looking for activity
    -e, --email                      Fetch the user email (can make the script take longer
    -o, --organization MANDATORY     Organization to scan for inactive users
    -v, --verbose                    More output to STDERR
    -h, --help                       Display this help

This utility finds users inactive since a configured date, writes those users to a file inactive_users.csv.

Installation

Clone this repository

git clone https://github.com/github/platform-samples.git
cd platform-samples/api/ruby/find-inactive-members

Install dependencies

gem install octokit

Configure Octokit

The OCTOKIT_ACCESS_TOKEN is required in order to see activities on private repositories. Also note that GitHub.com has an rate limit of 60 unauthenticated requests per hour, which this tool can easily exceed. Access tokens can be generated at https://github.com/settings/tokens. The OCTOKIT_API_ENDPOINT isn't required if connecting to GitHub.com, but is required if connecting to a GitHub Enterprise instance.

export OCTOKIT_ACCESS_TOKEN=00000000000000000000000     # Required if looking for activity in private repositories.
export OCTOKIT_API_ENDPOINT="https://<your_github_enterprise_instance>/api/v3" # Not required if connecting to GitHub.com.

Usage

ruby find_inactive_members.rb [-cehv] -o ORGANIZATION -d DATE

How Inactivity is Defined

Members are defined as inactive if they have not performed any of the following actions in any repository in the specified ORGANIZATION since the specified DATE:

  • Merged or pushed commits into the default branch
  • Opened an Issue or Pull Request
  • Commented on an Issue or Pull Request

Checkpoint

The script sometimes breaks while parsing large organization either caused by timeout or connection error. To deal with that frustration, checkpoint flag helps by storing Octokit API responses as json files in data/, so that during re-run it will first try to use stored json files instead of calling Github API from the beginning.

ruby find_inactive_members.rb [-cehv] -o ORGANIZATION -d DATE --checkpoint

Or simply do this (since it is idempotent)

while true; do ruby find_inactive_members.rb -o ORGANIZATION -d DATE --checkpoint; sleep 10; done

To reset the checkpoint files, simply

rm -rf data/*.json
rm -rf data/activities/*.json