Skip to content

Conversation

@alexandria7
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 looked at the seed data and determined based on that information that we would need a Customer model, Movie model, and a Rental indirect table to connect them.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. Because we are going through all of the customers/movies to get to those endpoints, our Big-O for both would be O(n) where n is the number of movies or customers.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. To get check-in, we have to look through potentially all of the customers to find the right ID, and do the same for movie ID. Based on this, our time complexity would be O(n + m) where n is the number of customers and m is the number of movies.
Describe a set of positive and negative test cases you implemented for a model. For our relation test for customer, a positive test was checking that it can have many movies, and a negative test case was checking that it can have no movies.
Describe a set of positive and negative test cases you implemented for a controller. When testing the index method for MoviesController, a positive test case was making sure that it can render all of the movies as well as the correct JSOn. A negative test case was to make sure it could render even if there were no movies.
How does your API respond when bad data is sent to it? It responds with JSON that displays an error message as well as a response code like 404.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We made a method in our Rental model that set the rental's check_out date and due_date before a rental's creation. We wrapped this into a method to clean up our check_out controller method.
Do you have any recommendations on how we could improve this project for the next cohort? I think some of the optionals seemed like they should be requirements, and it was a little confusing at times to understand if we actually needed to be writing certain code (we spent a day struggling with something that we realized later was an optional requirement).
Link to Trello https://trello.com/b/6xpD0Ds8/videostore-api
Link to ERD https://docs.google.com/document/d/1vg4XC85mO-6avi9VtGj3aJd7bxzqrGWq9iuiMXj7Un8/edit?usp=sharing
Summary

alexandria7 and others added 28 commits May 15, 2019 13:27
@dHelmgren
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene good
Comprehension questions good
General
Business Logic in Models some, see comment!
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
Overall Good work! Keep an eye out for any situation where your controllers are calculating or saving values! That's usually business logic.

def check_out
rental = Rental.new(rental_params)

if rental.movie.available_inventory > 0

Choose a reason for hiding this comment

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

You have a bunch of business logic here! Would it be possible to encapsulate this in a model method? Something like

rental.check_out(customer_id, movie_id)

might be a good interface. That would make this logic easier to test as well.

def show
movie = Movie.find_by(id: params[:id])
if movie
render json: movie.as_json(only: [:title, :overview, :release_date, :inventory, :available_inventory]), status: :ok

Choose a reason for hiding this comment

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

Small style note: not all text editors wrap lines for you. This line is so long that on GitHub I have to scroll horizontally to see all the pieces. You can make this easier to read by putting a newline after any given comma in a statement.

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