Skip to content

Conversation

@larachan15
Copy link

@larachan15 larachan15 commented Nov 10, 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. When we looked at the seed data, we found the common relationship between customers and movies were through rentals. We figured out that customers have many rentals through movies and that movies have many rentals through customers.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. We think it is O(n). Our method looks at every customer to get all of them. Looking at your code, I believe this is correct. However, there are some missing pieces in your analysis.

First, what is n? The number of movies or customers? You should specify this explicitly.

Second, what about finding the rental count? In your code you track this count in the database, so it doesn't add any extra time to the index operation. Are there other ways to do it that would?
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. We think this is also O(n). For our check_in method, we are using a model method called self.get_rental. This is a hash lookup which returns an array. We perform a .order on this which makes this a linear search. This is why we think it's O(n). Assuming that n is the number of Rentals, this is not quite correct. Calling .order sorts the entire list, which means the time complexity is O(n log(n)). However, since you only need the first matching rental, you don't need to call order, you could use .max_by instead and get linear complexity.
Describe a set of positive and negative test cases you implemented for a model. For the customer model we checked if the customer has a valid name, which would return true. If not, then it would return false.
Describe a set of positive and negative test cases you implemented for a controller. For the rentals controller, we checked that the available inventory incremented and decremented properly.
How does your API respond when bad data is sent to it? We have error messages set up, which are rendered when bad data is sent.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We made a get_rental method which would return a rental with a valid customer and movie id, with a due date that was earliest.
Do you have any recommendations on how we could improve this project for the next cohort? Maybe some more details or resources to read about using Postman. For instance, we didn't realize on the smoke tests, the order of the tests mattered. Somehow our order shifted and this made tests fail, when they should have been passing.
Link to Trello https://trello.com/b/sqNqcOx6/dionisia-karis
Link to ERD img_8126
Summary I liked working with my partner! Karis is great and rocks at testing. This was an interesting project and we learned a lot.

larachan15 and others added 30 commits November 5, 2018 11:32
created controllers and models
created tests for movies model
customers controller and tests complete
movies controllers and tests passing
…ustomers and added tests for those validations
@droberts-sea
Copy link

Video Store

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene yes
Comprehension questions yes - see inline feedback about computational complexity questions
General
Business Logic in Models some - see inline
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 - good use of a helper method to keep this DRY!
Overall Great work overall! This code is well-organized and does a good job of solving the problem at hand, and it is clear to me that the learning goals for this assignment were met. Keep up the hard work!

# binding.pry
if rental.save
rental.movie.increment_inventory!
rental.customer.decrement_movies_checked_out_count!

Choose a reason for hiding this comment

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

There's a lot of work being done in this function. Could you wrap this all up in a model method (maybe Rental.checkin(customer_id, movie_id)?

Choose a reason for hiding this comment

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

Also, what happens if the rental saves, but incrementing the inventory or decrementing the checkout count fails somehow? You would be in a sticky situation.

We didn't talk about this in class, but the solution here is to use a transaction. If you're interested in learning about this, see https://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html

# binding.pry
movie.decrement_inventory!
customer.increment_movies_checked_out_count!
# binding.pry

Choose a reason for hiding this comment

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

As above, it would be great to wrap all this up in a model method.

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