We can process data the way we did with ClickUp, using JSON and HTTP type providers or we can opt for the official GitHub library, Octokit to communicate with the API. With Octokit, once authenticated you can easily build your reports in Ruby, Node.js and .NET languages but there are third party libraries for other frameworks too.
The next few paragraphs will introduce methods for processing data from GitHub API.
Octokit in F#
The .NET documentation encourages us to write code in C# but a lazy coder like me prefers fewer lines. Also, we do not need to compile the code, our beloved F# Interactive will do the job instead.
We need a couple of packages:
- Octokit to get the data
- optionally, Deedle for data frames and statistics
- Xplot to present our reports.
You can try the API without authentication but that will limit you to 60 requests an hour. Authentication is easy once you registered your application at GitHub. GitHub requires a valid User-Agent value, so use the name of your application. Use your token the following way to establish a connection.
Get that data
client.Repository.GetAllForOrg() method needs only the name of the organization as a parameter. The signature of Task<IReadOnlyList<Repository>> tells us this is a task that is generating a list of repositories. The following lines count the repositories of bitrise-steplib where you can find the code of our workflow steps.
Process the data
For F# Deedle is what pandas are for Python: it has all the functions to process data in a tabular format. Let's draw a table of the number of forks, open issues and stargazers to understand which step has the most active community.
We can easily collect high-level figures with Deedle and its Stats namespace. This last contains members for several statistical indicators like mean, standard deviation or skewness etc.
Stay tuned for the next article on data wizardry titled Understanding Variance in User Attributes coming soon.