Based on requirements, this solution was built with the following attributes in view.
a. Made Sure the solution was Correct
b. keep to the principle of SOLID / DRY / KISS
c. Created Tests
d. Wrote Agnostic / Reusable Code
e. Used the Design patterns paradigm
f. this Documentation is comprehensive
The PHP version used is (PHP 8.1.6 (cli) (built: May 11 2022 08:55:59) (ZTS Visual C++ 2019 x64)).
The Symfony Version that was used (Symfony CLI version 5.4.12 © 2017-2022)
The Database Used was MariaDB
- Clone or download repository
https://github.com/josh3rill/LegalOne_Assessment.git
- Run composer
composer install
- Run installation script to create database and load fixtures
Make sure the Two Env Files are set to access the databse you will be using .env and .env.test
DATABASE_URL="mysql://root:@127.0.0.1:3306/LegalOne_test"
DATABASE_URL="mysql://root:@127.0.0.1:3306/LegalOne"
sh bin/install.sh
Note
The Log file should be Accessed directly from the C:/ Directory or from within the project.
–The default Log file in this project is Located in the Asset/Log Folder from the app root Directory.
The command line will be used to parse the file and upload the data of the Log file to a database.
make sure you use a bash console
- Run the Following Command
bin/console app:upload-data
but you will get an error message requesting for file path
Not enough arguments (missing: "FilePath").
- Run with the inclusion of a file part
bin/console app:upload-data C:/logs.txt
After generating , serve it with the internal Symfony server comes default with the CLI:
$ symfony server:start
Browse `http://127.0.0.1:8000` to Open in Browser
or use to following command to open the URL in a browser
symfony open:local
I built a RESTful service that implements the provided api.yaml
OpenAPI specs using the API platform.
Can be accessed by visiting the following link in your browser
`http://127.0.0.1:8000/api`
Implemented an API endpoint that counts the log entries in the database and return a sum.
{
“counter”: 21
}
`http://127.0.0.1:8000/api/count`
The api can be filtered by this Filters below
serviceNames | -> you can specify a service name to fetch result based on that
statusCode | -> you can specify a status code to filter the count result based on result that meets the criteria
date[between] | -> Specify a range of date that the result will produce it for you 17/Aug/2021:09:21:56…18/Aug/2020:10:32:56
TODO: optimize the search Filter for date
`http://127.0.0.1:8000/api/count?serviceNames=INVOICE-SERVICE&statusCode=201&date%5Bbetween%5D=17%2FAug%2F2021%3A09%3A21%3A56..18%2FAug%2F2020%3A10%3A32%3A56`
first run the Console Command test
php bin/phpunit tests/Command/UploadLogCommandTest.php
run the Api Counter test
php bin/phpunit tests/api/QueryDatabaseTest.php
you can also make use bin/phpunit only to run all the test
php bin/phpunit