Skip to content

Conversation

@Faiza1987
Copy link

@Faiza1987 Faiza1987 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. Seed data showed movies and customers, it doesn’t tell you much about the relationship but from that you could assume that a customer could potentially have many movies, which each movie could have many customers who rent it.Rentals therefore is what really joins together the movie and the customer. So rental would include both the movie_is and customer_id.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. Linear O(n) with n being the number of customers and movies. It depends on the number of customers in the system as well as the number of movies you have available for rental. More customers or movies increases the amount of time it will take to return the information for the action you need.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. Currently it is Constant O(1). When a checkin is performed, the action is performed on 1 movie only. However, it is very possible that in the future the rental contains multiple movies that have been checked out stored as an array. In that case it would be Linear O(n) with n being the number of movies that needs to be checked in.
Describe a set of positive and negative test cases you implemented for a model. set_checkin_date is a method in rental model. Positive test sets check in date to current and currently checked out too false. In a negative test case, if the movie is already checked out then it returns false.
Describe a set of positive and negative test cases you implemented for a controller. Our movies create method. Positive test case it that it successfully creates a new movie given valid data. Our movie count increases by 1, we render json which is a hash and includes an ID. When we look for that movie using the id, the movie will have the same title as the one created. In a negative test case in which we try to create a movie without a title, we render json which should be a hash, it must include errors along with a response of bad request.
How does your API respond when bad data is sent to it? It renders a json as false with a status of bad request as well as the error code associated with that request.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. Set_check_out date was one of the custom methods we created. It made more sense to have the logic that goes into setting date in the model as it is daily complex
Do you have any recommendations on how we could improve this project for the next cohort? Wave 3 and optional requirements blend into each other which can be a little confusing
Link to Trello Did not use a trello board in this case. As there was only 2 of us and we were in close proximity we could divide up the work as we went.
Link to ERD https://drive.google.com/file/d/17Th57MrorEM5yO5sa6ustUyUVWhiOuft/view?usp=sharing
Summary

@droberts-sea
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes
General
Business Logic in Models yes
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 Great work overall!

def checkout
rental = Rental.new(rental_params)

rental.set_checkout_date

Choose a reason for hiding this comment

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

I like the idea of making set_checkout_date be its own method. If you were to take this even further, you could write a class method on Rental that does both in one step.


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

Choose a reason for hiding this comment

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

I don't see that using strong params here gets you anything. It would be simpler to say:

Rental.find_by(movie_id: params[:movie_id], customer_id: params[:customer_id])

Since we're not using params directly to create or update a model (as in Rental.new(params)), we don't need the filtering that strong params gives us.

def movies_checked_out_count
currently_rented = Rental.where(customer_id: self.id, currently_checked_out: true)
return currently_rented.length
end

Choose a reason for hiding this comment

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

Because you have the relation on line 2, you could shorten line 14 to rentals.where(currently_checked_out: true).

Choose a reason for hiding this comment

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

I do love that you calculate this value on the fly instead of storing it in the database. That means there's no way to forget to update the count.

def available_inventory
checked_out_movies = Rental.where(movie_id: self.id, currently_checked_out: true)
avail_inventory = inventory - checked_out_movies.length
return avail_inventory

Choose a reason for hiding this comment

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

Similar comments to Customer#movies_checked_out_count


it "returns json" do
# Arrange - Act
get customers_path

Choose a reason for hiding this comment

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

The code you've written here matches what we showed in class. However, those tests were intentionally split out as a pedagogical tool. I think you could get away with collapsing all of these into one, since there's only one behavior you're covering.


get movie_path(invalid_movie_id)

must_respond_with :bad_request

Choose a reason for hiding this comment

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

Since your endpoint returns specific JSON in this case, it would be wise to verify that is sent correctly.

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