This project is not taking the project structure with pkg/
and cmd/
.
Because this is a simple project. A flat hierarchy is easier to read.
This application fails fast and replies with the corresponding HTTP status code. No pretty JSON response body will be given. Even though it is not hard to implement description error response. I am not overdoing on non requirement feature.
The analysed period will be dated back from last Monday to the (N)th week(s) before.
This application will not paranoid about the execution time which might cause big difference to the outcome due to that.
I am not using latest, at the time of writing, Go v1.21.5.
Because the linter golangci-lint
latest version is not supporting latest Go version.
I did not use custom error because this project is really simple. I cannot find a good place to use my custom error.
You may use the fast way to start the server without building it into binary.
Suppose you are using a POSIX shell environment with Make
utilities installed.
make run
Of course, you need to have Docker installed on your system.
make docker-image
docker run --rm -p 8080:8080 twaiv/workout-analytics
Apart from the above docker build
and docker run
commands. docker compose
manifest file is also provided.
To start as a detached suite
docker compose up -d
To tear down the suite
docker compose down
There is a JSON file in testdata
under the project directory for you to test. But the test is related to current date time.
The test data is during 2023-11-04 to 2023-11-26. You might not get any analysis, if you test very late and set the number of weeks too small.
Suppose you are using POSIX shell with cURL
installed. Following command can test the localhost server with the project test data file.
curl -v -H "Content-Type: application/json" --data-binary "@testdata/request.json" "http://localhost:8080/analyse?nweeks=48"