Skip to content

Conversation

@kdow
Copy link

@kdow kdow commented May 17, 2019

Video Store API

Congratulations! You're submitting your assignment!
If you didn't get to the functionality the question is asking about, reply with what you would have done if you had completed it.

Comprehension Questions

Question Answer
Explain how you came up with the design of your ERD, based on the seed data. We used the seeds to sketch out the fields that the tables would need and connected them based on relationships we saw that we needed
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. It's O(n) where n is the number of customers or movies. As the number of customers/movies increases, the time would increase. It has to touch each entry in the database to list them all.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. It would be O(n log n) because it implements binary search.
Describe a set of positive and negative test cases you implemented for a model. We tested validations for movie, for cases when it would be valid and invalid.
Describe a set of positive and negative test cases you implemented for a controller. We tested whether checking worked with valid data and invalid data.
How does your API respond when bad data is sent to it? It returns relevant error messages via JSON.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We added columns to the tables for movies and customers, we implemented custom methods to set the values of those columns after the instances were created.
Do you have any recommendations on how we could improve this project for the next cohort? More time explaining Postman and things that could help us interpret the smoke tests.
Link to Trello https://trello.com/b/s0SEs3Dd/videostore-api
Link to ERD https://drive.google.com/file/d/1PN60874ek4uiUlzJ4nc2yfQbqZCka06Z/view?usp=sharing
Summary

@CheezItMan
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene Good number of commits and mostly good commit messages, Not entirely sure.
Comprehension questions Check
General
Business Logic in Models Nope
All required endpoints return expected JSON data Check
Requests respond with appropriate HTTP Status Code Check
Errors are reported Check
Testing
Passes all Smoke Tests Check
Model Tests - all relations, validations, and custom functions test positive & negative cases For customer, no test on the number of items checked out, and no tests on the available inventory.
Controller Tests - URI parameters and data in the request body have positive & negative cases See my comments, you have some good tests, but could use a few specific additional tests.
Overall Nicely done, you hit all the learning goals here. See my inline comments as you could improve in your controller and model testing and building more business logic into the model. Let me know if you have questions.

has_many :rentals

after_create do |movie|
movie.available_inventory = movie.inventory

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This available_inventory makes better sense as a method instead of as a field. That way you don't have to engage in this chicanery.

Instead I suggest putting available_inventory method and movies_checked_out_count as methods in movie.rb and customer.rb.

it "returns JSON and the route is working" do
get customers_path, as: :json

expect(response.header["Content-Type"]).must_include "json"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also test the required keys.

body.length.must_equal Movie.count
end

it "returns movies with exactly the required fields" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

}
}

describe "checkout" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about checking out a movie with no available inventory left?

end

describe "check-in" do
let(:checkin_params) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you check in a movie that's not checked out?

if !customer
render json: { "errors": { "customer": ["Customer not found"] } }, status: :bad_request
else
checkout_date = Date.today

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at how much code is here... This would indicate a good case for a model method.

rental = Rental.find_by(customer_id: rental_params[:customer_id], movie_id: rental_params[:movie_id])

if rental
rental.movie.available_inventory += 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This business logic would look lovely in a model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants