Skip to content

Conversation

@evelynnkaplan
Copy link

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 treated a CustomerMovie as a "rental" and created a model/join table to represent that data, and that's how Customers connect to Movies.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. O(n), where n is the number of records in the database. This is because the amount of time it takes to look up every single record will depend on how many records there are.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. O(n) where n is the number of entries in the CustomerMovies table that correspond to the customer checking in a movie and the movie being checked in.
Describe a set of positive and negative test cases you implemented for a model. For the Customer_Movie.find_rentals method, we wrote a positive test where a CustomerMovie is found and returns one instance of a CustomerMovie. For a negative test, if a CustomerMovie is not found because of bad data, it returns nil.
Describe a set of positive and negative test cases you implemented for a controller. For the create method for the Movies Controller, we wrote a positive test creating a movie with good data and a negative test returning an error for bad data.
How does your API respond when bad data is sent to it? It returns a 404 or 400.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. The checkin and checkout methods are in model methods because the business logic of changing the movie's status and inventory, for example, belong in the model.
Do you have any recommendations on how we could improve this project for the next cohort?
Link to Trello
Link to ERD
Summary Wow! Amazing! Fun! Great pair!

@tildeee
Copy link

tildeee commented May 23, 2019

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene x
Comprehension questions x
General
Business Logic in Models nope, there is opportunity to bring some logic into models
All required endpoints return expected JSON data x
Requests respond with appropriate HTTP Status Code x
Errors are reported x
Testing
Passes all Smoke Tests
Model Tests - all relations, validations, and custom functions test positive & negative cases x
Controller Tests - URI parameters and data in the request body have positive & negative cases x
Overall

Well done!

Firstly, this project had many smoke tests that were failing. A lot of them actually get solved after a small change, which I have below in the comments.

That being said, the code was overall good. There are still some failing tests that I haven't looked into, and I think there's opportunity to bring some logic into model methods.

Also, I personally would think it's a better call to name the model Rental instead of CustomerMovie. I think that our hope going forward will be to name each class/model a "thing" that represents a solid/clear idea that has state, behavior, and relationships.

Otherwise, well done on this project!

def checkout
customer_movie = CustomerMovie.new(customer_movie_params)
if customer_movie.save
checkout_movie = customer_movie.movie.title
Copy link

Choose a reason for hiding this comment

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

Should we be setting checkout_movie to the value of its movie's title? This doesn't seem to break any tests, but it reads really strangely to me.

checkout_movie = customer_movie.movie.title
customer_movie.checkout_date = Date.today
customer_movie.due_date = Date.today.next_week
customer_movie.movie.inventory -= 1
Copy link

Choose a reason for hiding this comment

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

I think it would be really cool if all of this work around modifying customer_movie were pulled into an instance method on CustomerMovie! Imagine a method on CustomerMovie named checkout called with checkout_movie.checkout:

def checkout
  self.checkout_date = Date.today
  self.due_date = Date.today.next_week
  self.movie.inventory -= 1
end

customer_movie = CustomerMovie.where(customer_id: customer_movie_params[:customer_id], movie_id: customer_movie_params[:movie_id])
if customer_movie != []
customer_movie[0].movie.inventory += 1
customer_movie[0].status = "returned"
Copy link

Choose a reason for hiding this comment

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

Similar to above: it may be best if these two lines about incrementing inventory and changing status were pulled into an instance method. Even if it's two lines long, it's still helpful!

private

def movie_params
params.require(:movie).permit(:title, :overview, :release_date, :inventory)
Copy link

Choose a reason for hiding this comment

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

In Rails when we used forms, params would come back populated with a nested structure that had movie in it. In this API, we won't have that nested structure, so we need to take out the .require('movie') bit. When we do this, then most of Wave 2 starts working :)

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