A Sales Engine API for gathering and analyzing sales data built with Rails.
Pick your favorite directory, then:
git clone https://github.com/AliSchlereth/rales_engine.git
cd rales_engine
Run bundle. You'll need to be using Ruby 2.3.0. If you don't have that,
and you have rvm installed, you can run:
rvm install ruby-2.3.0 ... to get 2.3.0.
The Gemfile should automatically switch rubies for you when you open Rales Engine
but if not, you can do rvm use 2.3.0.
Check inside the db/data directory and make sure you have the following
CSV files: customers.csv, invoice_items.csv, invoices.csv, items.csv, merchants.csv, transactions.csv. If you don't, something has gone weird and you'll need to clone down
git clone https://github.com/turingschool-examples/sales_engine and copy the CSV
from that repo's data directory.
Cool.
Now, you'll need to make sure your PostgreSQL database is running. If you've got
a small elephant at the top of your screen: great. If not, spin up your PostgreSQL app.
(If you don't have the app, go here and follow the install instructions.)
Next: run the following command in your terminal:
rake db:create db:migrate db:test:prepare
Things will become briefly extremely exciting, then extremely calm.
You're not done yet. Run rake import to pull all of the CSV files into the database.
This will take some time, and you won't know it's done until you are returned to your terminal prompt.
While you wait you can hum a little song, or read some of that book, or go to this page and clone down the spec harness.
It's not strictly necessary for running Rales Engine but it'll help you put it through its paces.
Okay, all finished with rake import? Go ahead and run rspec - make sure all the
tests pass. If not, you might be missing a gem or maybe you should go back and run
rake db:test:prepare.
GET /api/v1/merchants/GET /api/v1/merchants/:idGET /api/v1/invoices/GET /api/v1/invoices/:idGET /api/v1/invoice_items/GET /api/v1/invoice_items/:idGET /api/v1/items/GET /api/v1/items/:idGET /api/v1/transactions/GET /api/v1/transactions/:idGET /api/v1/customers/GET /api/v1/customers/:id
GET /api/v1/merchants/:id/itemsreturns a collection of items associated with that merchantGET /api/v1/merchants/:id/invoicesreturns a collection of invoices associated with that merchant from their known orders
GET /api/v1/invoices/:id/transactionsreturns a collection of associated transactionsGET /api/v1/invoices/:id/invoice_itemsreturns a collection of associated invoice itemsGET /api/v1/invoices/:id/itemsreturns a collection of associated itemsGET /api/v1/invoices/:id/customerreturns the associated customerGET /api/v1/invoices/:id/merchantreturns the associated merchant
GET /api/v1/invoice_items/:id/invoicereturns the associated invoiceGET /api/v1/invoice_items/:id/itemreturns the associated item
GET /api/v1/items/:id/invoice_itemsreturns a collection of associated invoice itemsGET /api/v1/items/:id/merchantreturns the associated merchant
GET /api/v1/transactions/:id/invoicereturns the associated invoice
GET /api/v1/customers/:id/invoicesreturns a collection of associated invoicesGET /api/v1/customers/:id/transactionsreturns a collection of associated transactions
GET /api/v1/merchants/most_revenue?quantity=xreturns the topxmerchants ranked by total revenueGET /api/v1/merchants/most_items?quantity=xreturns the topxmerchants ranked by total number of items soldGET /api/v1/merchants/revenue?date=xreturns the total revenue for datexacross all merchants. Assume the dates provided match the format of a standard ActiveRecord timestamp.
GET /api/v1/merchants/:id/revenuereturns the total revenue for that merchant across successful transactionsGET /api/v1/merchants/:id/revenue?date=xreturns the total revenue for that merchant for a specific invoice datexGET /api/v1/merchants/:id/favorite_customerreturns the customer who has conducted the most total number of successful transactions.
*GET /api/v1/merchants/:id/customers_with_pending_invoicesreturns a collection of customers which have pending (unpaid) invoices. A pending invoice has no transactions with a result ofsuccess.
GET /api/v1/items/most_revenue?quantity=xreturns the topxitems ranked by total revenue generatedGET /api/v1/items/most_items?quantity=xreturns the topxitem instances ranked by total number soldGET /api/v1/items/:id/best_dayreturns the date with the most sales for the given item using the invoice date. If there are multiple days with equal number of sales, return the most recent day.
GET /api/v1/customers/:id/favorite_merchantreturns a merchant where the customer has conducted the most successful transactions
If you downloaded the test harness, you can test it out by cd'ing into it and
running bundle, then go back to your rales_engine directory in your terminal and run rails s
to start the server. Great. Now go back to the harness directory and run rake.
Enjoy all the pretty colors.
A Rails API storing a large amount of data in a PostgreSQL database. Tests written in rspec-rails, with dummy items coming from factory girl. Coverage provided by simplecov.