Skip to content

brianstorti/conversion-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conversions API

API to find conversion data in a csv.

Setup

Install the dependencies: bundle install
Run the tests: rake test
Check your style: rake rubocop
Setup the database: rake db:create db:schema:load import_csv
Run the server: rackup

Examples

Searching a conversion value for a specific date:

$ curl "http://localhost:9292/conversion?metric_id=15&date=2014-07-05"

{ "value": 9 }

Searching for a month:

$ curl "http://localhost:9292/conversion?metric_id=15&month=2014-07"

{ "value": 1 }

Searching for a date range:

$ curl "http://localhost:9292/conversion?metric_id=15&date=2015-04-27&end_date=2015-04-28"

{ "value": 0 }

Improvements

  • I'm just using sinatra-param's default error handling. Ideally I'd like to have better/custom error messages for each problem. (e.g. When a required query param is missing, it just says "Parameter is required".)

  • The csv search is very naive. It just loops through each line, sequentially, trying to find a match. This is not really a problem for this small sampling data (200ms in the worst case), just it can get embarrassing with a big csv.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages