Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #4

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
32b38bd
added js files for rentals, customers, movies routes
leahnp Jun 14, 2016
c58a53f
create index route to server it works json data
leahnp Jun 14, 2016
1e79dd1
added empty controllers
leahnp Jun 14, 2016
1146f58
added db dirs and files
leahnp Jun 14, 2016
05a8c0f
added controller scaffolding
leahnp Jun 14, 2016
2fed9bb
added routes to costumes and placeholder methods
leahnp Jun 14, 2016
923bffa
added routes to movies and placeholder methods
leahnp Jun 14, 2016
60a395b
completed routes and controller setup
leahnp Jun 14, 2016
ffb9db4
added scripts to package.json
leahnp Jun 14, 2016
7210590
create schema
leahnp Jun 14, 2016
609ea09
added vars to app js for db
leahnp Jun 14, 2016
017f585
create db and loaded schema
leahnp Jun 14, 2016
ac1de03
added seed js file to auto seed from our json data
leahnp Jun 15, 2016
1830723
deleted other file where we were trying to seed json data
leahnp Jun 15, 2016
1a9d7ad
seed success! seed js file working
leahnp Jun 15, 2016
f62cec9
no changes
leahnp Jun 16, 2016
5017a8d
Added Customer.all model method.
abrown152 Jun 16, 2016
2c1687c
Added Customer.all model and controller methods. Cleaned up funky code.
abrown152 Jun 16, 2016
94e3dd3
Added getMovie model and controller methods.
abrown152 Jun 16, 2016
0cb8c70
Structured the getRentals function and associated functions.
abrown152 Jun 16, 2016
7475951
EOD commit.
abrown152 Jun 16, 2016
66d9160
implemented customer sort
leahnp Jun 17, 2016
7272d8c
added sort movie functions
leahnp Jun 17, 2016
778a4b2
added rentals seed data
leahnp Jun 17, 2016
04a70b1
added function to return currently checked out videos for givien cust…
leahnp Jun 17, 2016
b245782
added get rental history for given id
leahnp Jun 17, 2016
481795d
working on returning data from movie and rentals models to get inventory
leahnp Jun 17, 2016
8f2444c
added instanbul
leahnp Jun 20, 2016
39b10c7
changed schema to include returned date
leahnp Jun 20, 2016
dec1418
added getpastchecked out method that returns past rentals and sorts b…
leahnp Jun 20, 2016
c948e37
added function to get all current customers who have checked out film…
leahnp Jun 20, 2016
273a5af
linked rentals & movies to use same function to return list of custom…
leahnp Jun 20, 2016
8a0f7ec
Break push.
abrown152 Jun 20, 2016
4f96be0
Slayed our own dragons.
abrown152 Jun 20, 2016
7cec0fa
working on getCheckout in rentals model, currently settime object is …
leahnp Jun 20, 2016
8546c07
fixed getCheck method to check out movie by name and customer id
leahnp Jun 21, 2016
43d3e46
make checkouts subtract 2 dollars from customer account balance
leahnp Jun 21, 2016
969b346
added returned method to return a rental
leahnp Jun 21, 2016
d2ac33e
working on getoverdue function, need to find object that will respond…
leahnp Jun 21, 2016
ff76112
getOverdue function.
abrown152 Jun 21, 2016
ec9af99
finished getoverdue with innerjoin query
leahnp Jun 21, 2016
101632c
got rentals/:title returning title, overview, release date, total inv…
leahnp Jun 22, 2016
25c8086
cleaned up commented out code and whitespace
leahnp Jun 22, 2016
35e9995
trying to setup test env everything is broken
leahnp Jun 22, 2016
59b985e
got test env config, can run npm run reset-test to create, schema, se…
leahnp Jun 22, 2016
c180749
changed dev db to be named _development
leahnp Jun 22, 2016
f55f4d0
Added basic customer controller tests.
abrown152 Jun 22, 2016
8983dfe
changed run test command, added tests to movies and rentals controllers
leahnp Jun 23, 2016
971e971
added test for customer model all method
leahnp Jun 23, 2016
17f324b
added test for customer sort model method
leahnp Jun 23, 2016
c1f3358
ignore coverage/ directory
leahnp Jun 24, 2016
106260f
switched views to render ejs, added docs ejs, route and controller
leahnp Jun 23, 2016
4c2b109
added json file, trying to find the best way to print it out in a view
leahnp Jun 23, 2016
7199638
changed rentals model error handling to be error or no results
leahnp Jun 23, 2016
dadc847
changed errors for no data found in db
leahnp Jun 23, 2016
383ddd9
changed error handling in customers controller to specify 500 or404
leahnp Jun 24, 2016
d838d4b
finished the rest of the error handling from the rentals model
leahnp Jun 24, 2016
d6d240a
finished the json docs for customers endpoint
leahnp Jun 24, 2016
367f88c
updated error handling for movies model when no data is found
leahnp Jun 24, 2016
2a6cc03
updated routes to handle for both no data and error 500
leahnp Jun 24, 2016
60d6347
finished docs for /movies endpoint
leahnp Jun 24, 2016
965f029
added html formatting for docs view to iterate through json file and …
leahnp Jun 24, 2016
62da41f
cleaned up commented out code and whitespace
leahnp Jun 24, 2016
148c82d
put .json route above view route to give higher priority
leahnp Jun 24, 2016
43b6264
fixed incorrect variable names and made = ==
leahnp Jun 24, 2016
af2d109
added two tests to movies model spec, checking valid and invalid movi…
leahnp Jun 24, 2016
955dace
Controller tests finished.
abrown152 Jun 24, 2016
4da180d
Added model tests.
abrown152 Jun 24, 2016
b2fc6f8
Finally got 90% test coverage. PR commit and byeeeeee
abrown152 Jun 24, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added function to return currently checked out videos for givien cust…
…omer id
leahnp committed Jun 17, 2016
commit 04a70b191bff5fda4e1b4e5c69549b64c59d284e
10 changes: 9 additions & 1 deletion controllers/customers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Customer = require("../models/customers_model");

var Rental = require("../models/rentals_model");


var CustomersController = {
@@ -29,7 +29,15 @@ var CustomersController = {

// customer id, all rentals attached to customer id within data params
getCustomersCurrent: function(req, res) {
Rental.getCurrentRentals(req.params.customer_id, function(error, data) {
if(error) {
var err = new Error("No such data");
err.status = 404;
} else {
res.json(data)
}

})
},

getCustomersHistory: function(req, res) {
9 changes: 9 additions & 0 deletions models/rentals_model.js
Original file line number Diff line number Diff line change
@@ -17,6 +17,15 @@ Rental.getCheckedOut = function(movie_id, callback) {
})
}

Rental.getCurrentRentals = function(customer_id, callback) {
db.rentals.where("customer_id=$1 AND returned=$2", [customer_id, false], function(error, checked_out) {
if(error) {
callback(error, undefined);
} else {
callback(null, checked_out);
}
})
}



4 changes: 2 additions & 2 deletions routes/customers.js
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ var Controller = require('../controllers/customers')
// select all from db
router.get('/', Controller.getCustomers)
router.get('/sort/:column', Controller.subsetCustomers)
router.get('/:id/current', Controller.getCustomersCurrent)
router.get('/:id/history', Controller.getCustomersHistory)
router.get('/:customer_id/current', Controller.getCustomersCurrent)
router.get('/:customer_id/history', Controller.getCustomersHistory)


module.exports = router;