Skip to content

Assessment Test which included piercing a file and uploading the data to a database Maira db was used

Notifications You must be signed in to change notification settings

josh3rill/Assessment

Repository files navigation

Assessment Documentation

Buit with Symfony Framework

Build Status
Attribution

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

Installation

  1. Clone or download repository
https://github.com/josh3rill/LegalOne_Assessment.git

  1. Run composer
composer install

  1. 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

Log Upload

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.

Custom Command Line

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

  1. 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"). 
  1. Run with the inclusion of a file part
bin/console app:upload-data C:/logs.txt

Starting Symfony Dev Server

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

Accessing API Documentation Based on OpenAPI Standard

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`

API endpoint Count

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`

Filtering the API endpoint 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`

Testing the Console Command and the Count Api with PHPUnit Test

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

About

Assessment Test which included piercing a file and uploading the data to a database Maira db was used

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published