Skip to content

Conversation

@snicodimos
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. Based on the seed data for movie and customer, we formatted our hash labels and data structures accordingly. We decided that rentals belonged to many customers and movies. Customers and movies had many rentals.
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) or linear where n is the size of Customer.all or Movie.all. The index methods (for both customer and movie) iterate through the array of hashes once and the time complexity would depend on how large n is.
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 constant. For every POST request the body of the request will always have the same number of parameters and it can only send a post for one entity at a time.
Describe a set of positive and negative test cases you implemented for a model. In our customer and movie models, we mainly tested for validations and relations. In our rental model, we have two custom methods rent_movie and return_movie both with positive cases. We didn’t add a negative case for them because the way those methods would be implemented in our RentalsController would assure only valid data.
Describe a set of positive and negative test cases you implemented for a controller. In RentalsController, we have a test for creating an instance of Rental with valid data and not creating a new instance of Rental with invalid data. Additionally, there is a test to throw an error if a valid movie does not have an available inventory greater than 0.
How does your API respond when bad data is sent to it? It responds with a render error of bad_request with a error message of what happened.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. All helper methods we used in out rental checkin and checkout methods (increment and decrement) is wrapped in a model methods. This made our controller methods DRY and more readable.
Do you have any recommendations on how we could improve this project for the next cohort? This was a non-stressful pair project (especially during mock interview week!) and we had a lot of fun! Postman testing / video instructions were informative and smooth.
Link to Trello https://trello.com/b/EIbzo4kN
Link to ERD https://www.lucidchart.com/invitations/accept/5bfc8285-2996-4dbe-9d42-b2d2e8b13b35
Summary :) :) :)

snicodimos and others added 30 commits November 5, 2018 11:27
@tildeee
Copy link

tildeee commented Nov 20, 2018

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene x
Comprehension questions With regards to Big O of POST /rentals/check-in: I'm pretty sure finding the right rental, customer, and movie all are linear time. Otherwise looks good :)
General
Business Logic in Models x
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 x
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

Hi Goeun and Semret! Y'all did a great job on this project!

I think this code looks really nice and clean. I think that you all also did a really wonderful job with organizing code. I think you both did a really great job of moving code to the best places it could be, in both application logic (controller and model) and tests.

Overall, the project passes all of the requirement, and it does so stylishly. Great work!

def movie_params
# 11 tests are failing and found out that we need to change the params from
# params.require(:movie)
# now 8 tests passed on postman
Copy link

@tildeee tildeee Nov 20, 2018

Choose a reason for hiding this comment

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

What is this comment in reference to so I can address it?

Copy link
Author

Choose a reason for hiding this comment

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

Oh these were our note for ourselves but we forgot to delete it in the final version. All of our tests pass. Sorry for the confusion.

rental.due_date = Date.today + 7
if rental.save

rental.rent_movie(customer, movie)
Copy link

Choose a reason for hiding this comment

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

I! Love! This! Method!


def find_movie
return Movie.find_by(id: rental_params[:movie_id])
end
Copy link

Choose a reason for hiding this comment

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

These private methods are great! It ends up making the code look so clean when it's used!


def rent_movie(customer, movie)
checked_out = customer.movies_checked_out_count
customer.update(movies_checked_out_count: checked_out +1)
Copy link

Choose a reason for hiding this comment

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

Minor syntax thing: Ruby linters complain if in Ruby you don't put a space before 1 (it would prefer + 1). Same with the minus sign below on line 20


inventory = movie.available_inventory
movie.update(available_inventory: inventory +1)
end
Copy link

Choose a reason for hiding this comment

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

These two methods are so wonderful and perfect. I want to show them off! This is exactly what I was looking for: You pulled out this logic into the Rental, which had logic that it delegated to customer and movie. Nicely done.

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