Skip to content

DanaMC18/restaurant_b_eats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Restaurant B-Eats

This application was created for a coding challenge. It was built using Ruby 2.3 and Rails 5.0.

The purpose of this challenge was to create a backend application that

  1. creates an ETL service to Extract, Transform, and Load a large CSV file of NYC Restaurant/Inspection data
  2. provides an API endpoint to search on this data

Database and Schema

This app uses a MySql 8.0 database. Included in the repo is the database schema and a database backup of about ~25k records.

ETL

The code related to ingesting the CSV file consists of

  • various services that read the CSV, parse each row, and load data into respective database tables
  • and a rake task -- it should be noted that the rake task takes in an optional parameter of ROW_COUNT. This argument was used when testing locally and to also limit the size of the production database in hopes of keeping it small/free.

API Endpoint

The end goal of this challenge was to provide an API endpoint that returns a list of restaurants based on a given "cuisine" (e.g. "Thai", "Pizza", etc) and NYC Inspection Grade (e.g. "A", "B", etc).

It was assumed that the results should include any restaurant with the specified Grade or better.

Using the Search

To GET a list of restaurants, a user can CURL against the following endpoint https://restaurant-b-eats.herokuapp.com/api/restaurants/search?cuisine=CUISINE_TYPE&grade=GRADE like so

$ curl https://restaurant-b-eats.herokuapp.com/api/restaurants/search?cuisine=pizza&grade=A

In addition to using CURL, a user can also visit the above URL in their browser.

Both cuisine and grade are optional parameters. But regardless, only restaurants with grades will be returned.

The Code

Code related to the above endpoint starts at the controller action.

The controller calls upon a builder service where the SQL Query for searching is written using ActiveRecord / Arel.

When the controller action receives results from the query builder, it serializes the restaurant data before rendering results in JSON.

Tests

The spec folder includes rspec tests for the ETL Services, the query builder, and the API Controller.

About

Coding challenge: API with only one working endpoint

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors