Skip to content

mMaydew/ratestask

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xeneta rates task

We are provided a postgres database as a docker container.

The task is as follows:

Develop an HTTP-based API capable of handling the GET request described below. Our stack is based on Flask, but you are free to choose any Python framework you like. All data returned is expected to be in JSON format. Please demonstrate your knowledge of SQL (as opposed to using ORM querying tools).

Implement an API endpoint that takes the following parameters:
    date_from
    date_to
    origin
    destination

and returns a list with the average prices for each day on a route between port codes origin and destination. Return an empty value (JSON null) for days on which there are less than 3 prices in total.

Both the origin, destination params accept either port codes or region slugs, making it possible to query for average prices per day between geographic groups of ports.

Initial setup

Create the containers for postgres and the API:

docker-compose up -d --build

The API will be available at 127.0.0.1:80

Testing

  • Windows:
py -m pip install -U pytest
py -m pytest --verbose
  • Unix based systems:
pip3 install -U pytest
pytest --verbose

Links to try

Returns prices and null:

Returns just prices:

Edge cases:

Total time usage

  • 3 hours 52 minutes (roughly)

About

Xeneta's Rate API task

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 97.1%
  • Dockerfile 2.9%