Coder Social home page Coder Social logo

candidate_homework's Introduction

Candidate Homework

Thank you for your interest in working with Catalyst! This repo is a boilerplate Rails 5.2 application that is in need of some work. Below are two prompts for changes that are needed. We want to see how you approach these challenges. Completing this work should not take more than two or three hours.

How to submit

To get started, please fork this repo, and create a new branch with your name. When finished working, open a pull request from your feature branch containing all of your changes, into the master branch within your fork. That way we can see the changes, comment, and ask questions.

Getting started

  • Install Postgres
  • Ensure there is a user called candidate_homework with an empty password, or update the username and password in config/database.yml
  • run rake db:create
  • run rake db:migrate
  • run rake db:seed

Prompt 1 - Data model changes and migration

You'll find an Integration model that holds connections in its config jsonb column, that looks like this:

{
  connections: [
    {
      auth: {
        username: 'postgres',
        password: 'postgres'
      },
      path: {
        host: 'localhost',
        database: 'analytics',
        table: 'users'
      },
      field_mapping: [
        ['user_local_field_1', 'user_external_field_1'],
        ['user_local_field_2', 'user_external_field_2'],
        ['user_local_field_3', 'user_external_field_3']
      ]
    },
    {
      auth: {
        username: 'postgres',
        password: 'postgres'
      },
      path: {
        host: 'localhost',
        database: 'analytics',
        table: 'orders'
      },
      field_mapping: [
        ['order_local_field_1', 'order_external_field_1'],
        ['order_local_field_2', 'order_external_field_2'],
        ['order_local_field_3', 'order_external_field_3']
      ]
    }
  ]
}

We'll say this model grew organically and required multiple connections to be stored in a single integration record. Now we need to split it up. We need to get individual records for elements in the field_mappings portion of a connection, while maintaining its connection to the path information.

  1. Add additional models where needed.
  2. Write database migrations to add the new table or tables.
  3. Write a script that can take the data added to the db through the database seed and put it into the new data model you design.

Evaluation

To evaluate, we will run the same steps as the "Getting started" section above, and then apply your changes. After your changes are applied we will run the new database migration(s) and your script for data migration. Please include instructions for how to run your scripts.

Prompt 2 - Maintain the API Contact

There is an Grape API file at app/api/api/integrations.rb that establishes the show view for a given Integration. The response looks like this:

{
    "id": 1,
    "name": "Integration 1",
    "connections": [
        {
            "path": "localhost.analytics.users",
            "field_mappings": [
                {
                    "local_field": "user_local_field_1",
                    "external_field": "user_external_field_1"
                },
                {
                    "local_field": "user_local_field_2",
                    "external_field": "user_external_field_2"
                },
                {
                    "local_field": "user_local_field_3",
                    "external_field": "user_external_field_3"
                }
            ]
        },
        {
            "path": "localhost.analytics.orders",
            "field_mappings": [
                {
                    "local_field": "order_local_field_1",
                    "external_field": "order_external_field_1"
                },
                {
                    "local_field": "order_local_field_2",
                    "external_field": "order_external_field_2"
                },
                {
                    "local_field": "order_local_field_3",
                    "external_field": "order_external_field_3"
                }
            ]
        }
    ]
}

After making your changes to the data model, ensure that this API endpoint returns the same set of data. Assume that there is a separately deployed front end application that relies on this endpoint.

Additionally, you'll find a API spec at spec/app/api/api/integrations_spec.rb that tests the output of this API endpoint. Note that this API tests against the development database. While a real application should load fixtures or factory objects into the database, to simplify the setup process for this homework we will test against the development database.

Evaluation

After running your database migration and data migration script, this API spec should still pass.

candidate_homework's People

Contributors

finleye avatar lzhou89 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.