Skip to content

Instantly share code, notes, and snippets.

@rodp
Last active October 25, 2018 14:09
Show Gist options
  • Save rodp/08e20a7d0d3bab86d8d255775743f5ee to your computer and use it in GitHub Desktop.
Save rodp/08e20a7d0d3bab86d8d255775743f5ee to your computer and use it in GitHub Desktop.
Coding Assignment

First and foremost: this assignment shouldn’t be too hard. Seriously. It contains no tricks and you don't need to be a genius to do it.

Basically, you just need to write a function and a test for it. We don't need you to write a REST API that you'll put into a Docker image and deploy to AWS. Please, don't do that. Just make some assumptions that seem sensible to you -- don't worry if you're not 100% sure -- and write some code we can later talk about.

The assignment aims to give us a glimpse of the decisions you make when you write real-world code. Ideally, the code should be readable, robust, optimal and tested: as if it will end up in production.

We recommend you use whatever language you feel strongest in. It doesn’t have to be one we use — we believe good developers can be productive in any language.

We won't give you any code or sample data on purpose. Ideally, you will read the description of the task and be able to make some sensible assumptions on your own. You can verify them by writing tests.

You may find gist.github.com useful for sharing the solution, but feel free to use anything else that is practical.


The context

  • Your clients send their users to your web application.
  • Each request comes with a unique user ID.
  • For each user who comes to your application, you collect some statistics, like the number of sessions.
  • You don't keep a copy of any of the users' identities.
  • Instead, each client lets you obtain the identities directly from one or more of their databases.
  • To generate a usage report for your client, you need to obtain and then combine identity data with statistics.

The task

Write a function that will take a list of user IDs and give you the name and the session count for each of those users.

To do that, you should assume the following:

These three dependencies already exist and can be used in your code (just require them and pretend they will be loaded):

  1. Metadata function: you give it a list of user IDs and it gives you a map where user IDs are keys and corresponding database IDs are values.
  2. Identity function: you give it a database ID (that you received from the metadata function) and a list of user IDs (that you expect to find in that database) and it gives you a map where user IDs are keys and their names are values.
  3. Statistics function: you give it a list of user IDs and it gives you a map where user IDs are keys and their session counts are values.

If any of these functions don’t find a match for a user ID, they will silently omit that user from the result.

All three functions perform network requests, so they might be slow and are prone to network errors.

Assume these functions have signatures that suit you the most (e.g., naming, input and output, etc.), so long as they keep the described functionality.

You can use any additional dependencies you find helpful.

Consider edge cases, like errors or missing data, and decide how to handle them.

Have in mind that the list of user IDs can be very long (e.g., thousands), while the number of identity databases is usually low (e.g., less than ten).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment