Skip to content

Conversation

@lbristol88
Copy link

@lbristol88 lbristol88 commented Nov 9, 2018

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 Feedback
Explain how you came up with the design of your ERD, based on the seed data. We first identified what models we needed and how they related to each other. A Customer has many rentals, a Movie has many rentals and a Rental and a customer and movie.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. We had to convert the models for customer and movie into json. The index method pulls all the instances of movie and convert it into the json format. The time complexity is O(log n). This is not quite accurate. First, you need to define n. Is it the number of customers, of movies, of rentals, the average number of rentals per customer...?

Second, taking movies as an example, we know this endpoint looks at all the movies because that's what is sent back as JSON. So if m is the total number of movies, then the time complexity is at least O(m).

Third, for each movie you call the available_inventory method, looking the collection of rentals, which implies there's an r term, where r is the number of rentals. This is where things start to get complicated, and depend on how postgres works - how long does it take to find the rentals for a given movie? Usually it's safe to assume that indexed data is organized using a tree, which means the time complexity is O(m log(r)).
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. In order to locate the rental we need to verify if a rental already exists and this gives us a time complexity of O(n). All other operations are constant. Again this depends on the internals of postgres, but because the Rental table is indexed by both movie ID and customer ID we get performance that is much closer to O(log(r)), where r is the total number of rentals.
Describe a set of positive and negative test cases you implemented for a model. In our model testing for movies, we checked to see if a movie is valid with inventory missing, which was our negative test case. Our position test case was to check if a movie was valid that had all the parameters.
Describe a set of positive and negative test cases you implemented for a controller. In our movies controller testing, we checked to see if index successfully returns a list of movies. Our negative test checked to see if it returns an empty an array for no movies.
How does your API respond when bad data is sent to it? Our API returns a json with error information.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. In our movie model, we created a custom method called available_inventory which returns the number of movies that are not currently checked out. We cannot hardcode the number of available inventory so we created the method in it's model.
Do you have any recommendations on how we could improve this project for the next cohort? We believe this was a well paced project. We were given ample time for the project which was very helpful in making sure that we met all the requirements.
Link to Trello
Link to ERD
Summary

@droberts-sea
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes - See inline feedback on time complexity. These are pretty complicated problems, so don't worry if your answer was a little off, the main point is to get practice!
General
Business Logic in Models yes - good work
All required endpoints return expected JSON data yes
Requests respond with appropriate HTTP Status Code yes
Errors are reported yes
Testing
Passes all Smoke Tests yes
Model Tests - all relations, validations, and custom functions test positive & negative cases yes
Controller Tests - URI parameters and data in the request body have positive & negative cases yes - missing some cases (see inline)
Overall Good work overall. This app is well-organized and does a good job of solving the problem, and it is clear that the learning goals for this assignment have been met. There are a few test cases that are missing, but in general I'm happy with what I see. Keep up the hard work!

#strong params
def customer_params
params.permit(:name, :registered_at, :address, :city, :state, :postal_code, :phone)
end

Choose a reason for hiding this comment

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

I don't think this method is used.

describe "index" do

it "successfully gets list of customers" do
get customers_path

Choose a reason for hiding this comment

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

What if there are no customers?

expect(body).must_include "errors"
end

describe "create" do

Choose a reason for hiding this comment

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

You forgot to end the previous describe block here.


it "does not successfully update if invalid" do

@rental.destroy

Choose a reason for hiding this comment

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

What if the rental has already been checked in?

it "does not successfully create if invalid" do

movie = Movie.find_by(id: rental_data[:movie_id] )
movie.destroy

Choose a reason for hiding this comment

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

What if there is not enough inventory?

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