Skip to content

cdcooksey/event-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Event Finder Demo App

The Project


Follow the Ruby on Rails Setup instructions below and seed the database with the geolocation information. Then complete the following tasks. Treat the code as if it were going to production.

Task 1 Implement JSON API endpoints to return seed data for one or more of the following scenarios.

# Input: Retailer ID
# Output: All events for a retailer

# Input: latitude, longitude, radius
# Output: All events within a radius

# Input: Retailer ID, Date
# Output: All events for a retailer on a given day

Task 2 Add a new table for receipts. The table should have the following information:

  • Store
  • Customer
  • Total Amount
  • Total Items
  • Date/Time

Task 3 Implement an API to create a new receipt

Task 4 Include test/specs for API.

Ruby on Rails Setup


This application requires:

  • Ruby (2.3.x)
  • Rails (5.x)

Learn more about Installing Rails.

Here's a quick install procedure for OSX Mavericks:

  1. Ensure XCode and Command Line Tools are installed
  2. Install brew
  3. Install the following brew packages
brew install git node pcre rbenv ruby-build sqlite3
  1. Ensure your rbenv profile is setup per the instructions printed during brew install, and possibly restart your terminal
  2. cd to the project root directory (where Gemfile is) and setup ruby
cd [project_directory]
rbenv install 2.3.1
rbenv rehash
gem install bundler
  1. initialize the application
bundle install
rake db:migrate
rake db:test:prepare
rake db:seed

Common rails commands:

  • bundle exec guard automatically runs the rails server as well as runs tests when files change
  • rake db:seed will always reload the given test data (will take a while)
  • rails console an interactive ruby console including the rails environment
  • rails db an interactive database console

Gems/Frameworks that are included but not mandatory to use:

  • Testing Framework: RSpec and Factory Girl
  • Continuous Testing: Guard and Spring

Getting a segfault on seed? Sorry about that - it's a bug with macOS sierra. Run this to get it fixed:

  brew update
  brew install sqlite3
  gem pristine sqlite3
  spring stop
  rake db:seed

Database


This application uses SQLite with ActiveRecord.

The tables given to you are stored in the .seed.csv files, and are loaded to your local sqlite database by the command rake db:seed

If you want to use another database (MySQL), you will need to configure databases.yml and then load the data there.

The database consists of sample data for 4 tables - customers, retailers, stores and events. The associated basic Rails models are included in the RoR project. A few notes:

  • Events are sample geolocation events for our customers (e.g. Enter geofence for a store location). event_at is the timestamp of when the geofence event was triggered on the mobile device. insert_dt is the timestamp of when the data was inserted into the database and can be ignored.
  • Stores and events are bounded by roughly 30 miles around downtown Denver and are from roughly a 3 week timeframe.
  • Lat/long on customers is the latitude and longitude of their home zip code.
  • You may ignore the offers and tasks data for the purposes of this project.