GitHub Repository Analytics with Filtering (GRAF) is a Rails web application that has the ability to collect and visually represent useful statistics on various GitHub repositories.
GRAF collects and stores GitHub information in its local data warehouse using a GitHub API wrapper called Octokit. Through Octokit, GRAF gathers information on every Pull Request and Commit for the selected repositories. Once this data has been successfully collected, our application allows the user to generate figures that are customized by timeframe, repository, company, etc.
Company affiliation is determined by querying each GitHub user's profile. If a user does not have an affiliated company listed on their profile, the application then checks to see whether the user is a member of any corporate Github organizations. If they are not, the user email is used to determine company affiliation.
These are the available metrics and options found on the Analytics page:
Metrics
- Commits
- Pull requests
- Average number of days a pull request is open
- Percent of pull requests merged
Views
- Pie Chart
- Bar Chart
- Line Chart
- Table
Group By / Filters
- Organization
- Month
- Quarter
- Year
- State
- Repo
- Company
- User Name
- Login Name
Additionally start and end date filters are available.
Deploying a GRAF instance on IBM's BlueMix
From the app's root directory do a push (see following command) and create an mysql db service.
cf push -c 'bundle exec rake db:create db:migrate' graf
This command will fail but will setup your database. Now delete your application using but do NOT delete your orphan database
cf delete graf
Now do another push and bind to the mysql database you created in the first push:
cf push graf
Your app should now be up and running.
- Modify the "config/graf/orgs.json" JSON file to select the organizations to load
- Open GRAF's /login page in a browser and enter a username / password
- Begin an initial load by going to /load and click the "Start Load" button
- Once the load is complete, the user can view the data on the /analytics and /report page
- Subsequent loads can be executed using "Start Load" button /load (Ensure there are enough api requests at /info)
Updating a GRAF instance on BlueMix
cf delete graf
cf create-service mysql 300 graf-db
cf push graf
http://graf.stage1.ng.bluemix.net/info
cf delete graf
cf push -c 'bundle exec rake db:create db:migrate' graf
cf delete graf
cf push graf
cf push graf
- Install Rails and MySQL
- Install bundled gems
- Create database in mysql console
CREATE DATABASE graf_db CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON graf_db.* TO 'graf_user'@'localhost' IDENTIFIED BY 'graf_password';
- Setup tables
bundle exec rake db:migrate
- Start server
rails s
Set up a Github Oauth token:
- Login to your github account at https://github.com/login
- Go to Github's Settings page at https://github.com/settings/applications
- Register an application (https://github.com/settings/applications/new) to get a Client ID and a Client Secret
- Generate a token (https://github.com/settings/tokens/new)
- Place the Client ID, Client Secret, and Access token into the settings.json file, which is located in the root directory (graf/config/graf/settings.json)