Skip to content

This repository contains the source code to satisfy the enext challenge

License

Notifications You must be signed in to change notification settings

bgildson/enext-challenge

Repository files navigation

ENEXT-CHALLENGE

Test Status Coverage Status Go Report Card

This repository contains the source code to satisfy the enext challenge.

How to run the challenge solution

To facilitate the command executions, the commands bellow will use Docker as runner. In case of need to run pieces of the solution, you should use Golang 1.14 with modules and install the dependencies.

Task 1

The first task was to create the Quake 3 log parser, run the command bellow to execute the parser.

docker run --rm -it -v $(pwd):/app -w /app golang:1.14 go run ./cmd/parser/main.go -log=./games.log -out=./games.json

The parser will generate a .json with the parsed games and should looks like the bellow representation.

{
  ...
  "2": {
    "id": "2",
    "total_kills": 11,
    "players": [
      "Isgalamido",
      "Mocinha"
    ],
    "kills": {
      "Isgalamido": -7,
      "Mocinha": 0
    }
  },
  ...
}

Task 2

The second task was to create the Game Report, the report has two output types, one for players results ranking grouped by game and other for players general results ranking. run the command bellow to execute the games report.

obs: the commands bellow depends of the task 1 command execution, because it uses the games.json parser output.

Report players results ranking grouped by game

docker run --rm -it -v $(pwd):/app -w /app golang:1.14 go run ./cmd/report/main.go -games-json-path=./games.json -general=false

The first report should looks the like bellow representation.

Game 1                              Total Kills: 0
Position | Player                         | Points

Game 2                             Total Kills: 11
Position | Player                         | Points
       1 | Mocinha                        | 0
       2 | Isgalamido                     | -7
...

Report players general results ranking

docker run --rm -it -v $(pwd):/app -w /app golang:1.14 go run ./cmd/report/main.go -games-json-path=./games.json -general=true

The second report should looks the like bellow representation.

General Ranking                  Total Kills: 1069
Position | Player                         | Points
       1 | Isgalamido                     | 138
       2 | Zeh                            | 120
       3 | Oootsimo                       | 108
...

Task 3

The third task was to create the api for games results, the api was created using a Clean Architecture minimum implementation and using the output from the parser as data source. The api has two endpoints /games to list the games and the /games/{id} to find the game by id.

obs: the commands bellow depends of the task 1 command execution, because it uses the games.json parser output.

docker run --rm -it -v $(pwd):/app -p 8080:8080 -w /app golang:1.14 go run ./cmd/api/main.go -games-json-path=./games.json -port=8080

The api will run on http://localhost:8080 and will provide one endpoint for /games and other for /games/{id}.

How to run the solution tests

All the code is covered by tests and to execute the tests use the command bellow.

docker run --rm -it -v $(pwd):/app -w /app golang:1.14 go test -v ./...

Languages