Skip to content

Instantly share code, notes, and snippets.

@alasarr
Created June 26, 2020 09:29
Show Gist options
  • Save alasarr/08a1deadd74bc8883e504b14be3d744e to your computer and use it in GitHub Desktop.
Save alasarr/08a1deadd74bc8883e504b14be3d744e to your computer and use it in GitHub Desktop.
Backend test

Choosing what to do during your next vacation

It’s summertime and we have decided we are going to Madrid for our vacation! However, we don’t know what to do when we get there. Thankfully, we’ve got a list of activities, so all that’s left is to write a program to help us decide where to go.

The goal of this project is to write a web API to help select activities to do in Madrid. We’re ambitious, and we’re thinking of expanding it to include data about multiple cities in the future, and adding more complicated planning, e.g: taking into account the transportation between different activities. In this exercise we’ll focus in the first steps towards that goal, but think of it as the first milestone in a bigger project.

We estimate this test should take around a day of work. Don’t worry if you finish faster, or if it takes you a little longer, as it can vary a lot depending on how you approach the project.

Keep in mind the following:

  • Please include a document with your code explaining your thought process during the test. The more you explain the decisions that you made, the better. We want to know the way you think. This is especially important on tradeoffs.
  • We are especially interested on how do you structure your code.
  • You can write this test on Python (AIOHTTP, Flask or Django), Ruby or NodeJS.
  • Please, make it easy to run and test.
  • Feel free to contact us for any questions about the test.
  • Your goal is to write a web API to show information about activities. Feel free to use any libraries you deem appropriate for the task, as long as they are available under an open source license.

Your program should:

  1. Load the provided activities file (madrid.json). It’s structured as JSON file with the following attributes:
  • Name of the activity
  • Opening hours. For each time of the week, an array of intervals when the place is open to visits
  • The average time in hours spent in the place
  • Category, location and district
  • Coordinates, expressed as an array with latitude and longitude
  1. Create an endpoint that returns all available activities
  • It should return all information about the available activities, in GeoJSON format
  • It should be able to filter by category, location or district. If no filter is provided, it should list all activities
  1. Create an endpoint to recommend what to do at a given time
  • The endpoint will receive a time range that the vacation-goer has available to perform an activity and the preferred category
  • It should return a single activity and all its details, in GeoJSON format
  • The returned activity should belong to the specified category and be open to the public at the time of visit. Keep in mind that the user will spend some time doing the activity (as specified in the activity description)
  • If there are multiple options, choose the one with the longest visit time that fits in the time range
  • Order the responses by longest visit time.

Additionally, we will want to extend the functionality in the future. There is no need to write code for the following part, but we’d like you to think about it and write some thoughts on how you would extend your program to add the following features:

  • Do not recommend an outdoors activity on a rainy day
  • Support getting information about activities in multiple cities
  • Extend the recommendation API to fill the given time range with multiple activities, taking into account the distances between them

When you are done, please upload your code and documentation to a GitHub repository (or any other platform) and send us the link.

[
{
"name": "El Rastro",
"opening_hours": {
"mo": [],
"tu": [],
"we": [],
"th": [],
"fr": [],
"sa": [],
"su": ["09:00-15:00"]
},
"hours_spent": 2.5,
"category": "shopping",
"location": "outdoors",
"district": "Centro",
"latlng": [40.4087357,-3.7081466]
},
{
"name": "Palacio Real",
"opening_hours": {
"mo": ["10:00-20:00"],
"tu": ["10:00-20:00"],
"we": ["10:00-20:00"],
"th": ["10:00-20:00"],
"fr": ["10:00-20:00"],
"sa": ["10:00-20:00"],
"su": ["10:00-20:00"]
},
"hours_spent": 1.5,
"category": "cultural",
"location": "outdoors",
"district": "Centro",
"latlng": [40.4173423,-3.7144063]
},
{
"name": "El Retiro",
"opening_hours": {
"mo": ["00:00-23:59"],
"tu": ["00:00-23:59"],
"we": ["00:00-23:59"],
"th": ["00:00-23:59"],
"fr": ["00:00-23:59"],
"sa": ["00:00-23:59"],
"su": ["00:00-23:59"]
},
"hours_spent": 1.5,
"category": "nature",
"location": "outdoors",
"district": "Retiro",
"latlng": [40.4154589,-3.6834559]
},
{
"name": "Casa de Campo",
"opening_hours": {
"mo": ["00:00-23:59"],
"tu": ["00:00-23:59"],
"we": ["00:00-23:59"],
"th": ["00:00-23:59"],
"fr": ["00:00-23:59"],
"sa": ["00:00-23:59"],
"su": ["00:00-23:59"]
},
"hours_spent": 3,
"category": "nature",
"location": "outdoors",
"district": "Latina",
"latlng": [40.4202185,-3.7481842]
},
{
"name": "Gran Vía",
"opening_hours": {
"mo": ["00:00-23:59"],
"tu": ["00:00-23:59"],
"we": ["00:00-23:59"],
"th": ["00:00-23:59"],
"fr": ["00:00-23:59"],
"sa": ["00:00-23:59"],
"su": ["00:00-23:59"]
},
"hours_spent": 1,
"category": "shopping",
"location": "outdoors",
"district": "Centro",
"latlng": [40.4199837,-3.7054455]
},
{
"name": "ECI Nuevos Ministerios",
"opening_hours": {
"mo": ["10:00-22:00"],
"tu": ["10:00-22:00"],
"we": ["10:00-22:00"],
"th": ["10:00-22:00"],
"fr": ["10:00-22:00"],
"sa": ["10:00-22:00"],
"su": ["10:00-22:00"]
},
"hours_spent": 2,
"category": "shopping",
"location": "indoors",
"district": "Chamberí",
"latlng": [40.4471904,-3.6932923]
},
{
"name": "Teatros del Canal",
"opening_hours": {
"mo": ["14:30-21:00"],
"tu": ["14:30-21:00"],
"we": ["14:30-21:00"],
"th": ["14:30-21:00"],
"fr": ["14:30-21:00"],
"sa": ["14:30-21:00"],
"su": ["14:30-21:00"]
},
"hours_spent": 1,
"category": "cultural",
"location": "indoors",
"district": "Chamberí",
"latlng": [40.4381495,-3.7052218]
},
{
"name": "Museo Nacional del Prado",
"opening_hours": {
"mo": ["10:00-20:00"],
"tu": ["10:00-20:00"],
"we": ["10:00-20:00"],
"th": ["10:00-20:00"],
"fr": ["10:00-20:00"],
"sa": ["10:00-20:00"],
"su": ["10:00-19:00"]
},
"hours_spent": 3,
"category": "cultural",
"location": "indoors",
"district": "Retiro",
"latlng": [40.413679,-3.6915639]
},
{
"name": "Parque del Oeste",
"opening_hours": {
"mo": ["00:00-23:59"],
"tu": ["00:00-23:59"],
"we": ["00:00-23:59"],
"th": ["00:00-23:59"],
"fr": ["00:00-23:59"],
"sa": ["00:00-23:59"],
"su": ["00:00-23:59"]
},
"hours_spent": 1,
"category": "nature",
"location": "outdoors",
"district": "Chamberí",
"latlng": [40.4273119,-3.7223896]
},
{
"name": "Templo de Debod",
"opening_hours": {
"mo": ["00:00-23:59"],
"tu": ["00:00-23:59"],
"we": ["00:00-23:59"],
"th": ["00:00-23:59"],
"fr": ["00:00-23:59"],
"sa": ["00:00-23:59"],
"su": ["00:00-23:59"]
},
"hours_spent": 0.5,
"category": "cultural",
"location": "outdoors",
"district": "Chamberí",
"latlng": [40.4244109,-3.7178539]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment