Coder Social home page Coder Social logo

josh3rill / assessment Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3.43 MB

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

Shell 2.38% PHP 19.57% JavaScript 23.50% CSS 50.43% HTML 2.59% Twig 1.53%
api apiplatform fopen symfony

assessment's Introduction

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

assessment's People

Contributors

josh3rill avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.