Given organisation calculates the top contributors by counting thier total contributions over the repositories. The contributors are sorted in descending order to have most active on top.
[
{
"name": "user1",
"contributions": 2017
},
{
"name": "user2",
"contributions": 1650
},
{
"name": "user3",
"contributions": 731
}
]
- Clone project
- Build the project
sbt compile
An API is built on top of GitHub REST API v3. First you must create a personal access token if you do not have one and assign it to environment variable with the name GH_TOKEN. The complete list of variables can be found in table.
Table 1: The list of available variables.
Variable name | Description | Required | Default |
---|---|---|---|
SERVER_HTTP_PORT | Server port | No | 8080 |
SERVER_CACHE_EXPIRY | Cached result expiry | No | 30 minutes |
SERVER_IDLE_TIMEOUT | Server response wait timeout | No | 5 minutes |
SERVER_CLIENT_TIMEOUT | Client response wait timeout | No | 1 minute |
GH_API_URL | GitHub API URL | No | https://api.github.com |
GH_MAX_CONCURRENT | Max concurrent requests to gather data | No | 100 |
GH_TOKEN | Personal access token | Yes | |
CIRCUIT_MAX_FAILURES | Circuit opening threshold | No | 5 |
CIRCUIT_RESET_TIMEOUT | Circuit drop timeout | No | 10 seconds |
To start service run
sbt run
Once service is running use an address http://localhost:8080/org/{org_name}/contributors where {org_name}
is some organisation name.
- scala 2.13.4 as the main application programming language
- http4s typeful, functional, streaming HTTP for Scala
- cats to write more functional and less boilerplate code
- cats-effect The Haskell IO monad for Scala
- pureconfig for loading configuration files
- refined for type constraints avoiding unnecessary testing and biolerplate
- scalatest and ScalaCheck for unit and property based testing
- wiremock to mock GitHub server