Skip to content

Instantly share code, notes, and snippets.

@pablomoniz
Last active September 29, 2020 15:05
Show Gist options
  • Save pablomoniz/014559356885c0d89c0c124ad3a61d5a to your computer and use it in GitHub Desktop.
Save pablomoniz/014559356885c0d89c0c124ad3a61d5a to your computer and use it in GitHub Desktop.
Support Backend engineer test

First part:

Let's warm up!

We would like to know how you would answer to customers questions. Please take a look at the code, try to find a solution, and write a reply to the client that includes a helpful and detailed answer.

As a deliverable, you can send us back a PDF with each answer. Remember that this first exercise is not only about your technical expertise but also about your communication skills, and that you'll find plenty of technical documentation at our Developer and Help Centers.

1.- Hello Support, I'm going through your materials, I've seen this query somewhere, and I'd need some help from your side on understanding what it does, can you give me a hand?

      SELECT e.name,
             count(*) AS counts,
             sum(p.population) as population
        FROM european_countries e
        JOIN populated_places p
          ON ST_Intersects(p.the_geom, e.the_geom)
    GROUP BY e.name

2.-Hi CARTO Support, I'm following your Dev Center's drawing example, but for some reason when I draw a circle no data is filtered. Can you give me a hand? You can find my code here, and a live version here. Thank you very much!

Second part: 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 don’t want to take too much of your time. We estimate this test should take you no longer than a couple of hours. 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 use any programming language and framework you want, so choose something that you feel comfortable with. In CARTO, you’ll be writing Ruby, so we’d prefer if you chose a similar language (procedural, dynamically typed, object oriented), but we’ll read your test as long as it’s not written in something like Malbolge ;)
  • Please, make it easy to run and test. It would be great if you provide an installation script, but a quick README is enough.
  • Feel free to contact us for any questions about the test. We’ll do our best to answer as quickly as possible. You can reach us at jtarrero@carto.com, pfmoniz@carto.com (CC all of us)
  • 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

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

When you are done, please upload your code and documentation to a GitHub repository (or any other

[
{
"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