Skip to content

Conversation

@aecombs
Copy link

@aecombs aecombs commented May 29, 2020

Assignment Submission: Video Store API

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

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.

Reflection

Prompt Response
Explain how you came up with the initial design of your ERD, based on the seed data and reading through the API endpoints We knew we would need to store data for customers, videos, and rentals. We also knew that rentals needed to have both info from customers and videos, so we decided to make an indirect relation to those so that customer has_many rentals, video has_many rentals, and rentals belongs_to both customer and video.
What would be the Big-O time complexity of your /customers & /videos endpoints? What does the time complexity depend on? Explain your reasoning. For index, it would be O(n) because it depends on how many of the customers and videos there are. For show, it would it O(1) because it will not matter how many customers/videos there are, we would know the id to look up and wouldn't need to search for it.
What is the Big-O time complexity of the POST /rentals/check-in endpoint? What does the time complexity depend on? Explain your reasoning. O(1) -- we're updating the data for the customer and the video, for which we have the ids. It will take the same amount of time no matter how many rentals/customers/videos there are.
Describe a specific set of positive and negative test cases you implemented for a model. We test for rentals to make sure they can be assigned a customer/video through the customer_id/video_id. The negative test checks validation on customer name.
Describe a specific set of positive and negative test cases you implemented for a controller. For rental's check-in action, we test to make sure we receive json as a response with all the correct fields. For the negative case, we test what happens with an invalid customer id.
Broadly, describe how an API should respond when it handles a request with invalid/erroneous parameters. We render json with the key "errors" and a message that says "Not Found", along with a 404 status.
Describe one of your custom model methods and why you chose to wrap that functionality into a method. We put the logic into the controller, which is something we might reflect if given more time to refine it.

Copy link

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

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

Good work on this project. Your code is well written and well tested. One smoke test failed -- the details in the rubric. It looks like you dealt with the situation of returning bad_request when the video inventory is 0, but not for an invalid video. Another thing to note is that you should put all business logic in the model. A good indicator of "business logic" is when you're manipulating data by adding or subtracting. Take a look and let me know if you have any questions. Keep up the hard work!


if rental.save

rental.customer.videos_checked_out_count = rental.customer.videos_checked_out_count + 1

Choose a reason for hiding this comment

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

This is business logic that deserves a custom model method.

customer = Customer.find_by(id:rental_params[:customer_id])
video = Video.find_by(id:rental_params[:video_id])

customer.videos_checked_out_count = customer.videos_checked_out_count - 1

Choose a reason for hiding this comment

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

Just as with check_out, you should encapsulate this logic with custom model methods(s)

@beccaelenzil
Copy link

beccaelenzil commented Jun 10, 2020

Video Store API

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Practices git with at least 10 small commits and meaningful commit messages ✔️
Understands the importance of how APIs handle invalid/erroneous data in their reflection questions ✔️
Practices Rails best practices and well-designed separation, and encapsulates business logic around check-out and check-in in models See in-line comment
Uses controller tests to ensure quality code for every route, and checks for response status and content, with positive cases and negative cases ✔️
Uses controller tests to ensure correctness for check out and check in requirement, and that checked out counts and inventories appropriately change ✔️

Functional Requirements

Functional Requirement yes/no
All provided smoke tests for Wave 1 pass ✔️
All provided smoke tests for Wave 2 pass Smoke test "Get errors when checking out invalid video" failed -- but I think it's a problem on my end! Will circle back.

Overall Feedback

Overall Feedback Criteria yes/no
Yellow (Approaches Standards) 2+ in Code Review && 1+ in Functional Requirements, or the instructor judges that this project needs special attention ✔️

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Descriptive/Readable
Logical/Organized

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