Skip to content

mikenotfound/maplecroft-tech-test

Repository files navigation

maplecroft-tech-test

Welcome to the maplecroft technical test.

This project contains an api only pre-built django application.

Maplecroft is a global risk analytics company that aims to standardise risk across a variety of different issues across the globe. Maplecroft refers to these issues as "indices", for example we have an environmental risk called Air Quality.

The project contains two simple models that represent an index (Index) and instance in time of that index (IndexVersion). The IndexVersion model has a score attribute that provides the 0-10 risk score at that particular time.

Getting started

To get started all you need is Docker:

Start the dev server for local development:

docker-compose up

Create a superuser to login to the admin:

docker-compose run --rm web ./manage.py createsuperuser

Load into some data

docker-compose run --rm web ./manage.py load_data

If you need to access the django shell you run

docker-compose run --rm web ./manage.py shell

Note

If you need to reload the database at any time simply re-run the load_data command


Tasks

Your task is to update the index app to include the following api endpoints (for further details see below)

  1. /index - this endpoint should return all indices
  2. /stats - this endpoint should return the max, min and median for all indices
  3. /{index_id}/windowed?time_from=<iso_string>&time_to=<iso_string> - this endpoint should return the windowed/average of values.

Task 1 - List indices

This endpoint lists all indices. We should be able to sort by name and filter by id

[{
    id: int
    name: string
}]

Task 2 - Stats

Return a list of stats objects that represent the maximum, minimum and median for each index e.g

[{
    id: int
    name: string
    mean: decimal
    max: decimal
    median: decimal
}]

Task 3 - Windowed/Average

A common way to display a large amount of historical data points on a graph is to average over a window.

It should accept two range query params that limit the returned scores, both time_from and time_to are required parameters.

For example, if we set the time_from and time_to window to be a 24h period, your challenge will be to aggregate all scores for this period and provide a single mean score.

[{
    id: int,
    name: string,
    averaged_scores: [{
        time_from: iso_format_string,
        time_to: iso_format_string, 
        score: # average of scores 
    }]
}]

Note

For each task please provide some simple unit tests. We do not expect all edge cases to be covered.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published