Skip to content

Conversation

@AngelaOh
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. The seed data gave us our models and needed fields. We also created our relationships based on our knowledge of rental systems and looked ahead at the checkin/checkout process in wave 3.
What would be the Big-O time complexity of your /customers & /movies endpoints? What does the time complexity depend on? Explain your reasoning. The Big-O for /customers and /movies would be O(n) where n is number customers or movies. It has to go through and collect every single item (customer or movie) so the time complexity would depend on how many 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. POST for /rentals/check-in would depend on what the time complexity of find_by is. If we are finding an element based on a key from a hash-like structure, the time complexity would constant whereas if the structure is an unsorted array, the time complexity would be linear where n is the number of items in movies.
Describe a set of positive and negative test cases you implemented for a model. In prepare for checkout, we looked at setting required fields that returned true for a positive test case and tested for a false return if the checkout was unable to save as our negative test case.
Describe a set of positive and negative test cases you implemented for a controller. In movies#show, a positive test was being able to get a movie and a negative test was returning an error if a movie was not found.
How does your API respond when bad data is sent to it? We handled this error by returning JSON that had an appropriate HTTP status code and a list of errors.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We created prepare_for_checkout in rental.rb. This method sets our checkout date, due date, and currently checked out status. We chose to wrap this because it felt like a lot of functionality to sit in the movies controller.
Do you have any recommendations on how we could improve this project for the next cohort? Not at this time!
Link to Trello https://trello.com/b/Eaop2GAO/video-store-project
Link to ERD See Angela's notebook for diagram. Movies has many rentals and has many customers through rentals. Customers has many rentals and has many movies through rentals. Rentals belong to movie and belong to customer.
Summary

AngelaOh and others added 30 commits May 14, 2019 11:23
Added Customer.rb Model Tests -relationships and a sample validation
Rental model custom method and tests
added available inventory and movies checked out count
@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 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 job overall, totally exemplary work!

def index
customers = Customer.all
# render json: { ok: true, customer: customers.as_json(only: [:id, :name, :register_at, :postal_code, :phone]) },
render json: customers.as_json(only: [:id, :name, :phone, :postal_code, :registered_at], methods: [:movies_checked_out_count]),

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.


validates :name, presence: true

def movies_checked_out_count

Choose a reason for hiding this comment

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

I love that you made Customer#movies_checked_out_count and Movie#available_inventory methods instead of storing them in the database. That way there's no way to forget to update these values.

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